Morgan-Stanley / morphir-elm / Morphir.Elm.Frontend

The Elm frontend turns Elm source code into Morphir IR.

Entry points

packageDefinitionFromSource : PackageInfo -> List SourceFile -> Result Errors (Morphir.IR.Package.Definition SourceLocation)

Function that takes some package info and a list of sources and returns Morphir IR or errors.

mapDeclarationsToType : SourceFile -> Elm.Syntax.Exposing.Exposing -> List Elm.Syntax.Declaration.Declaration -> Result Errors (List ( Morphir.IR.Name.Name, Morphir.IR.AccessControlled.AccessControlled (Morphir.IR.Documented.Documented (Morphir.IR.Type.Definition SourceLocation)) ))

Function that turns elm-syntax declarations to Morphir IR types.

Utilities


type alias ContentLocation =
{ row : Basics.Int
, column : Basics.Int 
}


type alias ContentRange =
{ start : ContentLocation
, end : ContentLocation 
}


type Error
    = ParseError String (List Parser.DeadEnd)
    | CyclicModules (Morphir.Graph.Graph () (List String))
    | ResolveError SourceLocation Resolve.Error
    | EmptyApply SourceLocation
    | NotSupported SourceLocation String
    | DuplicateNameInPattern Morphir.IR.Name.Name SourceLocation SourceLocation
    | VariableShadowing Morphir.IR.Name.Name SourceLocation SourceLocation
    | MissingTypeSignature SourceLocation
    | RecordPatternNotSupported SourceLocation


type alias Errors =
List Error


type alias PackageInfo =
{ name : Morphir.IR.Path.Path
, exposedModules : Set Morphir.IR.Path.Path 
}


type alias SourceFile =
{ path : String
, content : String 
}


type alias SourceLocation =
{ source : SourceFile
, range : ContentRange 
}