glimpse/typecheck
Values
pub fn constant(
environment: @internal Environment,
constant: glance.Constant,
) -> Result(
@internal EnvState(glance.Constant),
error.TypeCheckError,
)
Typecheck a module constant’s value and register it in the environment.
pub fn custom_type_constructors(
environment: @internal Environment,
custom_type: glance.CustomType,
) -> Result(@internal Environment, error.TypeCheckError)
Add all variant constructors of a custom type to the environment. Runs after every custom type in the module has been declared so forward references in variant fields resolve.
pub fn custom_type_declaration(
environment: @internal Environment,
custom_type: glance.CustomType,
) -> Result(@internal Environment, error.TypeCheckError)
Register a custom type’s name and type parameters in the environment.
Constructors are registered separately (see custom_type_constructors) so
that types referencing each other resolve regardless of declaration order.
pub fn function(
environment: @internal Environment,
function: glance.Function,
) -> Result(
@internal EnvState(glance.Function),
error.TypeCheckError,
)
Takes a glance function as input and returns the same function, but with the inferred return type if the original function did not have a return type. Returns an error if anything in the function doesn’t typecheck. The function signature in the environment may be updated with an inferred return type.
pub fn module(
glimpse_module: glimpse.Module,
module_envs: dict.Dict(String, @internal Environment),
target: @internal Target,
) -> Result(
#(glimpse.Module, @internal Environment),
error.TypeCheckError,
)
Infer and typecheck a single module in the given package. Any modules that this module imports must have already been inferred.
Returns a variation of the package where the module’s contents have been updated based on any inferences that were made.
pub fn package(
package: glimpse.Package,
target: @internal Target,
) -> Result(glimpse.Package, error.GlimpseError(a))
Infer and typecheck a glimpse package. Returns a new version of the package, where some glance types may have been replaced with inferred types.
Checks the main module and every module that is importable from that module.
Returns a GlimpseError if there are missing imports, circular dependencies, or anything in the AST fails to typecheck.
pub fn type_alias(
environment: @internal Environment,
alias: glance.TypeAlias,
) -> Result(@internal Environment, error.TypeCheckError)