finos/morphir-elm/6.1.0

NOTE: the latest version is 22.0.2

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

Morphir.Scala.AST

Scala's abstract-syntax tree. This is a custom built AST that focuses on the subset of Scala features that our generator uses. It's a relatively large portion of the language but it's not aiming to be complete.

Abstract Syntax Tree

type alias Name =
String
type alias Path =
List Name
type alias Documented a =
{ doc : Maybe String
, value : a
}
type alias Annotated a =
{ annotations : List String
, value : a
}
withAnnotation : List String -> a -> Annotated a

Wrap in Annotated with an annotation value.

withoutAnnotation : a -> Annotated a

Wrap in Annotated without any annotation values.

type alias CompilationUnit =
{ dirPath : List String
, fileName : String
, packageDecl : PackageDecl
, imports : List ImportDecl
, typeDecls : List (Documented (Annotated TypeDecl))
}
type alias PackageDecl =
List String
type alias ImportDecl =
{ isAbsolute : Bool
, packagePrefix : List String
, importNames : List ImportName
}
type Mod
= Sealed
| Final
| Case
| Val
| Package
| Implicit
| Private (Maybe String)
| Abstract
= Trait
{ modifiers : List Mod
, name : Name
, typeArgs : List Type
, extends : List Type
, members : List (Annotated MemberDecl)
}
| Class
{ modifiers : List Mod
, name : Name
, typeArgs : List Type
, ctorArgs : List (List ArgDecl)
, extends : List Type
, members : List (Annotated MemberDecl)
}
| Object
{ modifiers : List Mod
, name : Name
, extends : List Type
, members : List (Annotated MemberDecl)
, body : Maybe Value
}
type alias ArgDecl =
{ modifiers : List Mod
, tpe : Type
, name : Name
, defaultValue : Maybe Value
}
= ArgValue (Maybe Name) Value
= TypeAlias
{ alias : Name
, typeArgs : List Type
, tpe : Type
}
| ValueDecl
{ modifiers : List Mod
, pattern : Pattern
, valueType : Maybe Type
, value : Value
}
| FunctionDecl
{ modifiers : List Mod
, name : Name
, typeArgs : List Type
, args : List (List ArgDecl)
, returnType : Maybe Type
, body : Maybe Value
}
| MemberTypeDecl TypeDecl
type Type
= TypeVar Name
| TypeRef Path Name
| TypeApply Type (List Type)
| TypeParametrized Type (List Type) Type
| TupleType (List Type)
| StructuralType (List MemberDecl)
| FunctionType Type Type
| CommentedType Type String
type Value
= Literal Lit
| Variable Name
| Ref Path Name
| Select Value Name
| Wildcard
| Apply Value (List ArgValue)
| UnOp String Value
| BinOp Value String Value
| Lambda (List ( Name, Maybe Type )) Value
| Block (List MemberDecl) Value
| MatchCases (List ( Pattern, Value ))
| Match Value Value
| IfElse Value Value Value
| Tuple (List Value)
| StructuralValue (List ( Name, Value ))
| Unit
| This
| CommentedValue Value String
type Pattern
= WildcardMatch
| NamedMatch Name
| AliasedMatch Name Pattern
| LiteralMatch Lit
| UnapplyMatch Path Name (List Pattern)
| TupleMatch (List Pattern)
| EmptyListMatch
| HeadTailMatch Pattern Pattern
| CommentedPattern Pattern String
type Lit
= BooleanLit Bool
| CharacterLit Char
| StringLit String
| IntegerLit Int
| FloatLit Float

Utilities