elm-in-elm/compiler/1.0.1

Elm.AST.Canonical

Canonical AST is stripped of useless information, and generally tries to make life a bit more easier for compiler developers.

type alias ProjectFields =
{ modules : Dict ModuleName (Module LocatedExpr) }

"What does this compiler stage need to store abotut the whole project?

(See Elm.Data.Project.)

In this case, a dict of all the compiled Elm modules that hold canonical AST expressions.

type alias LocatedExpr =

The main type of this module. Expression with location metadata.

Note the underlying Expr custom type recurses on this LocatedExpr type, so that the children also each have their location metadata.

If you want expressions without location metadata, look at unwrap.

type Expr
= Int Int
| Float Float
| Char Char
| String String
| Bool Bool
| Var
{ module_ : ModuleName
, name : VarName
}
| Argument VarName
| Plus LocatedExpr LocatedExpr
| Cons LocatedExpr LocatedExpr
| Lambda
{ argument : VarName
, body : LocatedExpr
}
| Call
{ fn : LocatedExpr
, argument : LocatedExpr
}
| If
{ test : LocatedExpr
, then_ : LocatedExpr
, else_ : LocatedExpr
}
| Let
{ bindings : Dict VarName (Binding LocatedExpr)
, body : LocatedExpr
}
| List (List LocatedExpr)
| Unit
| Tuple LocatedExpr LocatedExpr
| Tuple3 LocatedExpr LocatedExpr LocatedExpr

Differs from Frontend.Expr by:

  • having fully qualified variables
  • having only single argument lambdas
unwrap : LocatedExpr -> Expr

Discard the location metadata.

fromUnwrapped : Expr -> LocatedExpr