finos/morphir-elm/16.0.0

NOTE: the latest version is 22.0.2

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

Morphir.IR.Package

A package is collection of types and values that are versioned together. If this sounds abstract just think of any of the popular package managers you are familiar with: NPM, NuGet, Maven, pip or Cabal. What they consider a package is what this represents. A package contains modules which further group types and values.

Specification vs Definition

Packages are available at two different levels of detail. A package specification only contains types that are exposed publicly and type signatures for values that are exposed publicly. A package definition contains all the details including implementation and private types and values.

type alias Specification ta =
{ modules : Dict ModuleName (Specification ta) }

Type that represents a package specification. A package specification only contains types that are exposed publicly and type signatures for values that are exposed publicly.

emptySpecification : Specification ta

Get an empty package specification with no modules.

type alias Definition ta va =
{ modules : Dict ModuleName (AccessControlled (Definition ta va))
}

Type that represents a package definition. A package definition contains all the details including implementation and private types and values. The modules field is a dictionary keyed by module name that contains access controlled module definitions. The AccessControlled adds access classifiers to each module to differentiate public and private modules.

emptyDefinition : Definition ta va

Get an empty package definition with no modules.

Lookups

lookupModuleSpecification : Path -> Specification ta -> Maybe (Specification ta)

Look up a module specification by its path in a package specification.

lookupModuleDefinition : Path -> Definition ta va -> Maybe (Definition ta va)

Look up a module definition by its path in a package specification.

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

Look up a type specification by its module path and name in a package specification.

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

Look up a value specification by its module path and name in a package specification.

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

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

Other utilities

type alias PackageName =
Path

A package name is a globally unique identifier for a package. It is represented by a path, which is a list of names.

definitionToSpecification : Definition ta va -> Specification ta

Turn a package definition into a package specification. Only publicly exposed modules will be included in the result.

definitionToSpecificationWithPrivate : Definition ta va -> Specification ta

Turn a package definition into a package specification. Non-exposed modules will also be included in the result.

eraseDefinitionAttributes : Definition ta va -> Definition () ()

Remove all type and value attributes from a package definition.

eraseSpecificationAttributes : Specification ta -> Specification ()

Remove all type attributes from a package specification.

mapDefinitionAttributes : (ta -> tb) -> (va -> vb) -> Definition ta va -> Definition tb vb

Map all type and value attributes of a package definition.

mapSpecificationAttributes : (ta -> tb) -> Specification ta -> Specification tb

Map all type attributes of a package specification.

selectModules : Set ModuleName -> PackageName -> Definition ta va -> Definition ta va

Filter down the modules in this distribution to the specified modules and their transitive dependencies.