finos / morphir-elm / Morphir.Elm.Frontend

The Elm frontend turns Elm source code into Morphir IR.

Entry points

packageDefinitionFromSource : Options -> PackageInfo -> Dict Morphir.IR.Path.Path (Morphir.IR.Package.Specification ()) -> List SourceFile -> Result Errors (Morphir.IR.Package.Definition SourceLocation 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

defaultDependencies : Dict Morphir.IR.Path.Path (Morphir.IR.Package.Specification ())

Dependencies that are added by default without explicit reference.


type alias Options =
{ typesOnly : Basics.Bool }

Options that modify the behavior of the frontend:

- `typesOnly` - only include type information in the IR, no values


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
    | TypeInferenceError SourceLocation Morphir.Type.Infer.TypeError


type alias Errors =
List Error


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


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


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

mapSource : Options -> PackageInfo -> Dict Morphir.IR.Path.Path (Morphir.IR.Package.Specification ()) -> List SourceFile -> Result (List Morphir.Compiler.Error) (Morphir.IR.Package.Definition SourceLocation SourceLocation)

mapValueToFile : Morphir.IR.Distribution.Distribution -> Morphir.IR.Type.Type () -> String -> Result String Morphir.IR.Distribution.Distribution

parseRawValue : Morphir.IR.Distribution.Distribution -> String -> Result String Morphir.IR.Value.RawValue

Parses an expression written in the Elm syntax into a RawValue.