glimpse
Types
pub type LoadError(a) {
LoadError(a)
ParseError(
glance_error: glance.Error,
module_name: String,
module_content: String,
)
}
Constructors
-
LoadError(a)
-
ParseError( glance_error: glance.Error, module_name: String, module_content: String, )
pub type Module {
Module(
name: String,
module: glance.Module,
dependencies: List(String),
)
}
Constructors
-
Module( name: String, module: glance.Module, dependencies: List(String), )
A Module is a wrapper of a glance.Module, but maintains some additional information such as the name of the package and the names of any dependencies of that module.
pub type Package {
Package(name: String, modules: dict.Dict(String, Module))
}
Constructors
-
Package(name: String, modules: dict.Dict(String, Module))
A Package has a name and a collection of modules. Each module is named according to its import. A module can be converted to a filename (relative to the global source / directory) simply by appending ‘.gleam’
Functions
pub fn filter_new_dependencies(
module: Module,
package: Package,
) -> List(String)
given a module and package, identify any dependencies in the module that are not present in the package, and return them as a list.
The dependencies will be a list of strings like gleam/io
or glance
pub fn load_module(
module: Module,
name: String,
) -> glimpse.Module
Given an existing Gleam Module and its name, parse its imports to determine what its dependencies are. Return a Glimpse Module that wraps the Gleam module.
Note: If the returned Module has any dependencies, it is up to the caller to ensure they are loaded, along with their dependencies.
pub fn load_package(
package_name: String,
loader: fn(String) -> Result(String, a),
) -> Result(Package, LoadError(a))
Load a package using just it’s name and a loader function. The name is required to be identical to the entry point module for the package (which is normal in gleam packages).
Recursively loads all imports in the entrypoint using the supplied loader function.