gleamgen/import_
Types
One entry in an import path.{ … } exposing list.
pub type ExposedItem {
ExposedType(name: String, alias: option.Option(String))
ExposedValue(name: String, alias: option.Option(String))
}
Constructors
-
ExposedType(name: String, alias: option.Option(String))Renders as
type nameortype name as alias. -
ExposedValue(name: String, alias: option.Option(String))Renders as
nameorname as alias.
pub type ImportedModule {
ImportedModule(
name: List(String),
alias: option.Option(String),
exposing: List(ExposedItem),
before_text: String,
predefined: Bool,
)
}
Constructors
-
ImportedModule( name: List(String), alias: option.Option(String), exposing: List(ExposedItem), before_text: String, predefined: Bool, )
Values
pub fn exposed_type(name: String) -> ExposedItem
pub fn exposed_type_as(
name: String,
alias: String,
) -> ExposedItem
pub fn exposed_value(name: String) -> ExposedItem
pub fn exposed_value_as(
name: String,
alias: String,
) -> ExposedItem
pub fn function0(
imported: ImportedModule,
func: fn() -> ret,
) -> expression.Expression(fn() -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module. Useful for importing functions and automatically getting their types Note that the function does not check if the provided function actually exists in the module.
let dict_module = import_.new(["gleam", "dict"])
let dict_new = import_.function1(dict_module, dict.new)
// dict.new ^ is a reference to actual function from gleam/dict
// Therefore this type checks:
expression.call0(dict_new)
// but this does not:
expression.call1(dict_new, expression.int(46))
pub fn function1(
imported: ImportedModule,
func: fn(a) -> ret,
) -> expression.Expression(fn(a) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module. Useful for importing functions and automatically getting their types Note that the function does not check if the provided function actually exists in the module.
let io_module = import_.new(["gleam", "io"])
let io_println = import_.function1(io_module, io.println)
// io.println ^ is a reference to actual function from gleam/io
// Therefore this type checks:
expression.call1(io_println, expression.string("Hello, World!"))
// but this does not:
expression.call1(io_println, expression.int(46))
pub fn function2(
imported: ImportedModule,
func: fn(a, b) -> ret,
) -> expression.Expression(fn(a, b) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function3(
imported: ImportedModule,
func: fn(a, b, c) -> ret,
) -> expression.Expression(fn(a, b, c) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function4(
imported: ImportedModule,
func: fn(a, b, c, d) -> ret,
) -> expression.Expression(fn(a, b, c, d) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function5(
imported: ImportedModule,
func: fn(a, b, c, d, e) -> ret,
) -> expression.Expression(fn(a, b, c, d, e) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function6(
imported: ImportedModule,
func: fn(a, b, c, d, e, f) -> ret,
) -> expression.Expression(fn(a, b, c, d, e, f) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function7(
imported: ImportedModule,
func: fn(a, b, c, d, e, f, g) -> ret,
) -> expression.Expression(fn(a, b, c, d, e, f, g) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function8(
imported: ImportedModule,
func: fn(a, b, c, d, e, f, g, h) -> ret,
) -> expression.Expression(fn(a, b, c, d, e, f, g, h) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn function9(
imported: ImportedModule,
func: fn(a, b, c, d, e, f, g, h, i) -> ret,
) -> expression.Expression(fn(a, b, c, d, e, f, g, h, i) -> ret)
Deprecated: use import_.value_of_type and types.reference instead
Import an existing function from the module.
See function1 for more details.
pub fn merge_imports(
imports: List(ImportedModule),
) -> List(ImportedModule)
pub fn new(name: List(String)) -> ImportedModule
pub fn raw_ident(
imported: ImportedModule,
name: String,
) -> expression.Expression(any)
pub fn raw_type(
imported: ImportedModule,
name: String,
) -> custom.CustomType(t, generics)
pub fn value_of_type(
imported: ImportedModule,
name: String,
type_: types.GeneratedType(t),
) -> expression.Expression(t)
pub fn with_alias(
imported: ImportedModule,
alias: String,
) -> ImportedModule
pub fn with_exposing(
imported: ImportedModule,
exposing: List(ExposedItem),
) -> ImportedModule
pub fn with_predefined(
imported: ImportedModule,
predefined: Bool,
) -> ImportedModule
When True, the import line is always emitted even if static analysis finds
no reference to the module prefix (e.g. types only nested inside other ASTs).