the-sett/elm-syntax-dsl/1.2.1

NOTE: the latest version is 6.0.5

Elm.CodeGen

Elm.CodeGen is a DSL designed to make it easier to write Elm code that generates Elm code.

Types describing parts of the Elm AST.

type alias Comment =
String

Comments are just Strings.

type alias Documentation =
String

Documentation is just Strings.

type alias ModuleName =
List String

A module name can consist of mulitple Stirngs separated with '.'.

type alias Module =
Module

The AST for an Elm module.

type alias File =
File

The AST for an Elm file.

type alias Declaration =
Declaration

The AST for a top-level Elm declaration; a function, a value, a type or a type alias.

type alias Import =
Import

The AST for an Elm import statement.

type alias TypeAnnotation =
TypeAnnotation

The AST for an Elm type annotation.

type alias Exposing =
Exposing

The AST for an Elm exposing statement.

type alias TopLevelExpose =
TopLevelExpose

The AST for a member of an Elm exposing statement.

type alias Expression =
Expression

The AST for an Elm expression.

type alias Pattern =
Pattern

The AST for a de-structuring Elm pattern matching expression.

Functions for building Elm source files.

file : Module -> List Import -> List Declaration -> List Comment -> File

Assembles all the components of an Elm file; the module declaration, the comments, the imports and the top-level declarations.

Functions for building module declarations.

normalModule : ModuleName -> List TopLevelExpose -> Module

NormalModule DefaultModuleData

portModule : ModuleName -> List TopLevelExpose -> Module

PortModule DefaultModuleData

Functions for building an exposing statement.

all : Exposing

All Range

explicit : List TopLevelExpose -> Exposing

Explicit (List (Node TopLevelExpose))

infixExpose : String -> TopLevelExpose

InfixExpose String

functionExpose : String -> TopLevelExpose

FunctionExpose String

typeOrAliasExpose : String -> TopLevelExpose

TypeOrAliasExpose String

typeExpose : ExposedType -> TopLevelExpose

TypeExpose ExposedType

openExposedType : String -> ExposedType

Creates an exposing member for a type, exposing all of the types constructors.

closedExposedType : String -> ExposedType

Creates an exposing member for an opaque type, exposing none of its constructors.

Functions for building import statements.

import_ : ModuleName -> Maybe ModuleName -> Maybe Exposing -> Import

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.

Incrementally build up import and export lists.

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.

type alias ImportsAndExposing =
( List Import, List TopLevelExpose )

Captures lists of imports and exposings of a module, allowing these to be built up dynamically as code generation progresses.

deDupeImportsAndExposing : List ImportsAndExposing -> ImportsAndExposing

Simplifies the imports and exposings by removing any duplicates.

emptyImportsAndExposing : ImportsAndExposing

Creates empty imports and exposings lists.

addImport : Import -> ImportsAndExposing -> ImportsAndExposing

Adds an import to the list.

addExposing : TopLevelExpose -> ImportsAndExposing -> ImportsAndExposing

Adds an exposing to the list.

Functions for building top-level declarations.

Maybe Documentation
-> Maybe Signature
-> String
-> List Pattern
-> Expression
-> Declaration

FunctionDeclaration Function

Maybe Documentation
-> String
-> List String
-> TypeAnnotation
-> Declaration

AliasDeclaration TypeAlias

Maybe Documentation
-> String
-> List String
-> List ( String, List TypeAnnotation )
-> Declaration

CustomTypeDeclaration Type

portDeclaration : String -> TypeAnnotation -> Declaration

PortDeclaration Signature

destructuring : Pattern -> Expression -> Declaration

Destructuring (Node Pattern) (Node Expression)

Functions for building Elm type signatures.

signature : String -> TypeAnnotation -> Signature

Creates a type signature.

Functions for building Elm expressions.

pipe : Expression -> List Expression -> 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 |> d
chain : Expression -> List Expression -> Expression

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 >> d
unitExpr : Expression

UnitExpr

application : List Expression -> Expression

Application (List (Node Expression))

operatorApplication : String -> InfixDirection -> Expression -> Expression -> Expression

OperatorApplication String InfixDirection (Node Expression) (Node Expression)

functionOrValue : ModuleName -> String -> Expression

FunctionOrValue ModuleName String

simpleVal : String -> Expression

Creates a FunctionOrValue with no qualifiying module.

ifBlock : Expression -> Expression -> Expression -> Expression

IfBlock (Node Expression) (Node Expression) (Node Expression)

prefixOperator : String -> Expression

PrefixOperator String

operator : String -> Expression

Operator String

integer : Int -> Expression

Integer Int

hex : Int -> Expression

Hex Int

floatable : Float -> Expression

Floatable Float

negation : Expression -> Expression

Negation (Node Expression)

literal : String -> Expression

Literal String

charLiteral : Char -> Expression

CharLiteral Char

tupledExpression : List Expression -> Expression

TupledExpression (List (Node Expression))

parenthesizedExpression : Expression -> Expression

ParenthesizedExpression (Node Expression)

letExpression : LetBlock -> Expression

LetExpression LetBlock

caseExpression : CaseBlock -> Expression

CaseExpression CaseBlock

lambdaExpression : Lambda -> Expression

LambdaExpression Lambda

recordExpr : List RecordSetter -> Expression

RecordExpr (List (Node RecordSetter))

listExpr : List Expression -> Expression

ListExpr (List (Node Expression))

recordAccess : Expression -> String -> Expression

RecordAccess (Node Expression) (Node String)

recordAccessFunction : String -> Expression

RecordAccessFunction String

recordUpdateExpression : String -> List RecordSetter -> Expression

RecordUpdateExpression (Node String) (List (Node RecordSetter))

glslExpression : String -> Expression

GLSLExpression String

Functions for building de-structuring pattern matchings.

allPattern : Pattern

AllPattern

unitPattern : Pattern

UnitPattern

charPattern : Char -> Pattern

CharPattern Char

stringPattern : String -> Pattern

StringPattern String

intPattern : Int -> Pattern

IntPattern Int

hexPattern : Int -> Pattern

HexPattern Int

floatPattern : Float -> Pattern

FloatPattern Float

tuplePattern : List Pattern -> Pattern

TuplePattern (List (Node Pattern))

recordPattern : List String -> Pattern

RecordPattern (List (Node String))

unConsPattern : Pattern -> Pattern -> Pattern

UnConsPattern (Node Pattern) (Node Pattern)

listPattern : List Pattern -> Pattern

ListPattern (List (Node Pattern))

varPattern : String -> Pattern

VarPattern String

namedPattern : QualifiedNameRef -> List Pattern -> Pattern

NamedPattern QualifiedNameRef (List (Node Pattern))

asPattern : Pattern -> String -> Pattern

AsPattern (Node Pattern) (Node String)

paranthesizedPattern : Pattern -> Pattern

ParenthesizedPattern (Node Pattern)

Functions for building Elm type annotations.

genericType : String -> TypeAnnotation

GenericType String

typed : ModuleName -> String -> List TypeAnnotation -> TypeAnnotation

Typed (Node ( ModuleName, String )) (List (Node TypeAnnotation))

unit : TypeAnnotation

Unit

tupled : List TypeAnnotation -> TypeAnnotation

Tupled (List (Node TypeAnnotation))

record : List ( String, TypeAnnotation ) -> TypeAnnotation

Record RecordDefinition

genericRecord : String -> List ( String, TypeAnnotation ) -> TypeAnnotation

GenericRecord (Node String) (Node RecordDefinition)

functionTypeAnnotation : TypeAnnotation -> TypeAnnotation -> TypeAnnotation

FunctionTypeAnnotation (Node TypeAnnotation) (Node TypeAnnotation)