I want to import a type constructor, but not a type itself.
For example, I need to use a None
from an Option
type:
import gleam/option.{type None}
pub type MyType {
MyType(value: Option(Int))
}
pub fn build_type() {
MyType(None)
}
However, this code doesn’t compile:
error: Unknown module type
┌─ /src/main.gleam:1:22
│
1 │ import gleam/option.{type None}
│ ^^^^^^^^^ Did you mean `Option`?
The module `gleam/option` does not have a `None` type.
None
is not a type, but a type constructor. Type constructors don’t need a type
keyword in the import
statement:
import gleam/option.{None}