Morgan-Stanley/morphir-elm/3.0.0

Renamed to finos/morphir-elm. It is published under that name, and new versions come out there.

Versions published as Morgan-Stanley/morphir-elm still install under that name. 5 versions of 5 come from the new location (see their notes).

Rerouted (renamed, needs approval). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/finos/morphir-elm.

What we checked: The repo moved to github.com/finos/morphir-elm and tag 3.0.0 is there; its commit 5fb93bcdc077 is from 2020-10-29 14:07 UTC, after the version was published (2020-08-17 21:31 UTC); elm.json differs from package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.

We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:

  • lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,
  • LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,
  • LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.

Details · package.elm-lang.org's zip: https://github.com/Morgan-Stanley/morphir-elm/zipball/3.0.0/

Morphir.IR.Type

This module contains the building blocks of types in the Morphir IR.

Type Expression

type Type a
= Variable a Name
| Reference a FQName (List (Type a))
| Tuple a (List (Type a))
| Record a (List (Field a))
| ExtensibleRecord a Name (List (Field a))
| Function a (Type a) (Type a)
| Unit a

An opaque representation of a type. Check out the docs for each building blocks for more details:

Creation

variable : a -> Name -> Type a

Creates a type variable.

toIR a == variable [ "a" ] ()


toIR fooBar == variable [ "foo", "bar" ] ()
reference : a -> FQName -> List (Type a) -> Type a

Creates a fully-qualified reference to a type.

toIR (List Int)
    == reference SDK.List.listType [ intType ]


toIR Foo.Bar
    == reference
        ( [ [ "my" ], [ "lib" ] ], [ [ "foo" ] ], [ "bar" ] )
        []
tuple : a -> List (Type a) -> Type a

Creates a tuple type.

toIR ( Int, Bool )
    == tuple [ basic intType, basic boolType ]
record : a -> List (Field a) -> Type a

Creates a record type.

toIR {} == record []


toIR { foo = Int }
    == record
        [ field [ "foo" ] SDK.Basics.intType
        ]


toIR { foo = Int, bar = Bool }
    == record
        [ field [ "foo" ] SDK.Basics.intType
        , field [ "bar" ] SDK.Basics.boolType
        ]
extensibleRecord : a -> Name -> List (Field a) -> Type a

Creates an extensible record type.

toIR { e | foo = Int }
    == extensibleRecord (variable [ "e" ])
        [ field [ "foo" ] intType
        ]


toIR { f | foo = Int, bar = Bool }
    == extensibleRecord (variable [ "f" ])
        [ field [ "foo" ] intType
        , field [ "bar" ] boolType
        ]
function : a -> Type a -> Type a -> Type a

Creates a function type. Use currying to create functions with more than one argument.

toIR (Int -> Bool) ==
    function
        SDK.Basics.intType
        SDK.Basics.boolType


toIR (Int -> Bool -> Char) ==
    function
        intType
        (function
            SDK.Basics.boolType
            SDK.Basics.charType
        )
unit : a -> Type a

Creates a unit type.

toIR () == unit

Record Field

type alias Field a =
{ name : Name
, tpe : Type a
}

An opaque representation of a field. It's made up of a name and a type.

mapFieldName : (Name -> Name) -> Field a -> Field a

Map the name of the field to get a new field.

mapFieldType : (Type a -> Type b) -> Field a -> Field b

Map the type of the field to get a new field.

Specification

= TypeAliasSpecification (List Name) (Type a)
| OpaqueTypeSpecification (List Name)
| CustomTypeSpecification (List Name) (Constructors a)
customTypeSpecification : List Name -> Constructors a -> Specification a

Definition

type Definition a
= TypeAliasDefinition (List Name) (Type a)
| CustomTypeDefinition
(List Name)
(AccessControlled (Constructors a))

This syntax represents a type definition. For example:

  • type alias Foo a = {bar : Maybe a, qux : Int}
  • type MyList a = End | Cons a (MyList a)

In the definition, the List Name refers to type parameters on the LHS and Type extra refers to the RHS

typeAliasDefinition : List Name -> Type a -> Definition a
customTypeDefinition : List Name -> AccessControlled (Constructors a) -> Definition a

Constructors

type alias Constructors a =
List (Constructor a)
= Constructor Name (List ( Name, Type a ))

Mapping

mapTypeAttributes : (a -> b) -> Type a -> Type b
(Type a -> Result e (Type b))
-> Result (List e) (Definition b)