finos/morphir-elm/22.0.0

NOTE: the latest version is 22.0.2

Formerly Morgan-Stanley/morphir-elm. Search finds this package by either name.

Morphir.IR.Module

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.

type alias ModuleName =
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.

type alias QualifiedModuleName =
( 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.

Specification vs Definition

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.

type alias Specification ta =
{ types : Dict Name (Documented (Specification ta))
, values : Dict Name (Documented (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:

  • types: a dictionary of local name to documented type specification.
  • values: a dictionary of local name to value specification.
emptySpecification : Specification ta

Get an empty module specification with no types or values.

type alias Definition ta va =
{ types :
Dict Name (AccessControlled (Documented (Definition ta)))
, values :
Dict Name (AccessControlled (Documented (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:

  • types: a dictionary of local name to access controlled, documented type specification.
  • values: a dictionary of local name to access controlled value specification.

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.

Lookups

lookupTypeSpecification : Name -> Specification ta -> Maybe (Specification ta)

Look up a type specification by its name in a module specification.

lookupValueSpecification : Name -> Specification ta -> Maybe (Specification ta)

Look up a value specification by its name in a module specification.

lookupValueDefinition : Name -> Definition ta va -> Maybe (Definition ta va)

Look up a value definition by its name in a module specification.

Manage attributes

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 FQName

Collect all type references from the module.

collectValueReferences : Definition ta va -> Set FQName

Collect all value references from the module.

collectReferences : Definition ta va -> Set 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.