Elm.CodeGen is a DSL designed to make it easier to write Elm code that generates Elm code.
elm-syntax also permits effects modules, but with kernel code restrictions you cannot use these so
they have been ommitted from the DSL.
NormalModule DefaultModuleData
PortModule DefaultModuleData
All Range
Explicit (List (Node TopLevelExpose))
TypeExpose ExposedType
FunctionExpose String
TypeExpose ExposedType
TypeOrAliasExpose String
Creates an Elm import statement; the name of the module, an optional alias name for the module, and an optional list of exposings from the module.
This is useful during code generation where the exact imports and exports are not known in advance but depend on what code is actually generated. Each section of code generation can declare the imports and exposings that it needs and they can be combined and de-duplicated to produce a final list.
I have used the name Linkage to refer to the combination of a modules imports and exports. It describes
how a module is linked to other modules.
Linkage describes the lists of imports and exposings of a module and allows these to be built up incrementally as code generation progresses.
Adds an exposing to the list.
Adds an import to the list.
Simplifies the imports and exposings by removing any duplicates.
Creates empty imports and exposings lists.
AliasDeclaration TypeAlias
CustomTypeDeclaration Type
FunctionDeclaration Function
Destructuring (Node Pattern) (Node Expression)
PortDeclaration Signature
RecordAccess (Node Expression) (Node String)
RecordAccessFunction String
Application (List (Node Expression))
CaseExpression CaseBlock
Joins multiple expressions together with the function chain operator >>. An
expression a combined with a list of expressions [b, c, d] results in:
a >> b >> c >> dCharLiteral Char
Floatable Float
FunctionOrValue ModuleName String
FunctionOrValue ModuleName String
Note this is the same as fqFun
Creates a FunctionOrValue with no qualifiying module.
GLSLExpression String
Hex Int
IfBlock (Node Expression) (Node Expression) (Node Expression)
Integer Int
LambdaExpression Lambda
LetExpression LetBlock
ListExpr (List (Node Expression))
Negation (Node Expression)
Operator String
OperatorApplication String InfixDirection (Node Expression) (Node Expression)
ParenthesizedExpression (Node Expression)
Joins multiple expressions together with the pipe operator |>. An
expression a combined with a list of expressions [b, c, d] results in:
a |> b |> c |> dPrefixOperator String
Literal String
TupledExpression (List (Node Expression))
UnitExpr
RecordUpdateExpression (Node String) (List (Node RecordSetter))
Creates a FunctionOrValue with no qualifiying module.
Note this is the same as fun.
AllPattern
AsPattern (Node Pattern) (Node String)
CharPattern Char
FloatPattern Float
NamedPattern QualifiedNameRef (List (Node Pattern))
HexPattern Int
IntPattern Int
ListPattern (List (Node Pattern))
NamedPattern QualifiedNameRef (List (Node Pattern))
ParenthesizedPattern (Node Pattern)
RecordPattern (List (Node String))
StringPattern String
TuplePattern (List (Node Pattern))
UnConsPattern (Node Pattern) (Node Pattern)
UnitPattern
VarPattern String
GenericRecord (Node String) (Node RecordDefinition)
Typed (Node ( ModuleName, String )) (List (Node TypeAnnotation))
FunctionTypeAnnotation (Node TypeAnnotation) (Node TypeAnnotation)
Record RecordDefinition
Tupled (List (Node TypeAnnotation))
GenericType String
Typed (Node ( ModuleName, String )) (List (Node TypeAnnotation))
Unit
A Bool type annotation.
An Int type annotation.
A Float type annotation.
A String type annotation.
A Char type annotation.
Creates a List type annotation.
Creates a Set type annotation.
Creates a Dict type annotation.
Creates a Maybe type annotation.
Creates a type signature.
These types are all declared in elm-syntax but are re-exported here for convenience.
A module name can consist of mulitple Stirngs separated with '.'.
The AST for an Elm module.
The AST for an Elm file.
The AST for a top-level Elm declaration; a function, a value, a type or a type alias.
The AST for an Elm import statement.
The AST for an Elm type annotation.
The AST for an Elm exposing statement.
The AST for a member of an Elm exposing statement.
The AST for an Elm expression.
The AST for a de-structuring Elm pattern matching expression.
Assembles all the components of an Elm file; the module declaration, the comments, the imports and the top-level declarations.