glimpse/target
Types
The build target that a package is being typechecked for. Definitions
annotated with @target(erlang), @target(javascript), or a custom target
name are only active for their target; definitions without a target
attribute apply to all.
Erlang and Javascript are the targets the real compiler builds for, and
Named(name) supports experimental backends with their own target names
(e.g. @target(python)).
pub type Target {
Erlang
Javascript
Named(name: String)
}
Constructors
-
Erlang -
Javascript -
Named(name: String)
Values
pub fn filter_for_target(
module: glance.Module,
target: Target,
) -> glance.Module
Remove definitions whose @target attribute does not match the active
target. The real Gleam compiler performs this filtering before typechecking
so that e.g. the @target(javascript) variant of a type or function is not
seen when checking for erlang.
pub fn function_supported(
target: Target,
definition: glance.Definition(glance.Function),
) -> Bool
Whether a function definition is usable on the given target: pure Gleam
functions and functions with a body run everywhere, while a body-less
external function runs only on the targets its @external attributes name.
pub fn has_external_for_target(
target: Target,
definition: glance.Definition(glance.Function),
) -> Bool
Whether a function’s @external attributes include one for the given
target. A function with such an external uses the external implementation
on this target and its Gleam body is not checked; a function whose
externals are for other targets uses its body instead.