Syntax for the different top-level declarations in Elm.
These can be one of the following (all declared in Declaration
):
- Functions:
add x y = x + y
- Custom types:
type Color = Blue | Red
- Type aliases:
type alias Status = Int
- Port declaration:
port sendMessage: String -> Cmd msg
- Destructuring:
{name, age} = person
- Infix declarations. You will probably not need this, while only core packages can define these.
Types
type Declaration = FunctionDeclaration Elm.Syntax.Expression.Function
| AliasDeclaration Elm.Syntax.TypeAlias.TypeAlias
| CustomTypeDeclaration Elm.Syntax.Type.Type
| PortDeclaration Elm.Syntax.Signature.Signature
| InfixDeclaration Elm.Syntax.Infix.Infix
| Destructuring (Elm.Syntax.Node.Node Elm.Syntax.Pattern.Pattern) (Elm.Syntax.Node.Node Elm.Syntax.Expression.Expression)
Custom type that represents all different top-level declarations.
Serialization
encode : Declaration -> Json.Encode.Value
Encode a Declaration
syntax element to JSON.
decoder : Json.Decode.Decoder Declaration
JSON decoder for a Declaration
syntax element.