finos/morphir-elm/17.0.0

NOTE: the latest version is 22.0.2

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

Morphir.IR

This module contains data structures and functions to make working with the IR easier and more efficient.

type alias IR =
{ valueSpecifications : Dict FQName (Specification ())
, valueDefinitions : Dict FQName (Definition () (Type ()))
, typeSpecifications : Dict FQName (Specification ())
, typeConstructors :
Dict FQName ( FQName, List Name, List ( Name, Type () ) )
}

Data structure to store types and values efficiently.

Conversions

fromPackageSpecifications : Dict PackageName (Specification ()) -> IR

Turn a dictionary of package specifications into an IR.

Turn a Distribution into an IR. The Distribution data type is optimized for transfer while the IR data type is optimized for efficient in-memory processing.

Lookups

typeSpecifications : IR -> Dict FQName (Specification ())

Get all type specifications.

lookupTypeSpecification : FQName -> IR -> Maybe (Specification ())

Look up a type specification by fully-qualified name. Dependencies will be included in the search.

lookupTypeConstructor : FQName -> IR -> Maybe ( FQName, List Name, List ( Name, Type () ) )

Look up a type constructor by fully-qualified name. Dependencies will be included in the search. The function returns a tuple with the following elements:

  • The fully-qualified name of the type that this constructor belongs to.
  • The type arguments of the type.
  • The list of arguments (as name-type pairs) for this constructor.
lookupValueSpecification : FQName -> IR -> Maybe (Specification ())

Look up a value specification by fully-qualified name. Dependencies will be included in the search.

lookupValueDefinition : FQName -> IR -> Maybe (Definition () (Type ()))

Look up a value definition by fully-qualified name. Dependencies will not be included in the search.

Utilities

empty : IR

Creates an empty IR with no types or values.

resolveAliases : FQName -> IR -> FQName

Follow direct aliases until the leaf type is found.

resolveType : Type () -> IR -> Type ()

Fully resolve all type aliases in the type.

resolveRecordConstructors : Value ta va -> IR -> Value ta va

Replace record constructors with the corresponding record value.