Modules are used to group types and values together to make them easier to find. A module serves the same purpose as a package in Java or namespaces in other languages. A module is identified by a module name within the package. Within a module each type and value is identified using a local name.
Morphir.IR.Path.Path
A module name is a unique identifier for a module within a package. It is represented by a path, which is a list of names.
( Morphir.IR.Path.Path
, Morphir.IR.Path.Path
)
A qualified module name is a globally unique identifier for a module. It is represented by a tuple of the package and the module name.
Modules are available at two different levels of detail. A module specification only contains types that are exposed publicly and type signatures for values that are exposed publicly. A module definition contains all the details including implementation and private types and values.
{ types : Dict Morphir.IR.Name.Name (Morphir.IR.Documented.Documented (Morphir.IR.Type.Specification ta))
, values : Dict Morphir.IR.Name.Name (Morphir.IR.Documented.Documented (Morphir.IR.Value.Specification ta))
, doc : Maybe String
}
Type that represents a module specification. A module specification only contains types that are exposed publicly and type signatures for values that are exposed publicly.
A module contains types and values which is represented by two field in this type:
emptySpecification : Specification ta
Get an empty module specification with no types or values.
{ types : Dict Morphir.IR.Name.Name (Morphir.IR.AccessControlled.AccessControlled (Morphir.IR.Documented.Documented (Morphir.IR.Type.Definition ta)))
, values : Dict Morphir.IR.Name.Name (Morphir.IR.AccessControlled.AccessControlled (Morphir.IR.Documented.Documented (Morphir.IR.Value.Definition ta va)))
, doc : Maybe String
}
Type that represents a module definition. A module definition contains all the details including implementation and private types and values.
A module contains types and values which is represented by two field in this type:
Type variables ta and va refer to type annotation and value annotation
emptyDefinition : Definition ta va
Get an empty module definition with no types or values.
definitionToSpecification : Definition ta va -> Specification ta
Turn a module definition into a module specification. Only publicly exposed types and values will be included in the result.
definitionToSpecificationWithPrivate : Definition ta va -> Specification ta
Turn a module definition into a module specification. Non-exposed types and values will also be included in the result.
lookupTypeSpecification : Morphir.IR.Name.Name -> Specification ta -> Maybe (Morphir.IR.Type.Specification ta)
Look up a type specification by its name in a module specification.
lookupValueSpecification : Morphir.IR.Name.Name -> Specification ta -> Maybe (Morphir.IR.Value.Specification ta)
Look up a value specification by its name in a module specification.
lookupValueDefinition : Morphir.IR.Name.Name -> Definition ta va -> Maybe (Morphir.IR.Value.Definition ta va)
Look up a value definition by its name in a module specification.
eraseSpecificationAttributes : Specification ta -> Specification ()
Remove all type attributes from a module specification.
eraseDefinitionAttributes : Definition ta va -> Definition () ()
Remove all type attributes from a module definition.
mapDefinitionAttributes : (ta -> tb) -> (va -> vb) -> Definition ta va -> Definition tb vb
mapSpecificationAttributes : (ta -> tb) -> Specification ta -> Specification tb
collectTypeReferences : Definition ta va -> Set Morphir.IR.FQName.FQName
Collect all type references from the module.
collectValueReferences : Definition ta va -> Set Morphir.IR.FQName.FQName
Collect all value references from the module.
collectReferences : Definition ta va -> Set Morphir.IR.FQName.FQName
Collect all type and value references from the module.
dependsOnModules : Definition ta va -> Set QualifiedModuleName
Find all the modules that this module depends on.