Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Contains all AST elements, all of these produced by the Parser module.
Synopsis
- newtype Program = Program [Statement]
- data Statement
- data Declaration
- data Expression
- data Fun = Fun (NonEmpty (Identifier, Maybe Type)) (Maybe Type) Expression
Program
The head of the AST.
Statements
Statement.
StmtDecl Declaration | Declaration statement, see |
StmtExpr Expression | Expression statement, see |
Declarations
data Declaration Source #
Declaration.
DeclVar (Identifier, Maybe Type) Expression | Variable declaration. let x = 5 |
DeclFun Identifier IsRec Fun | Function declaration. let f x y = x + y let rec f x y = f x 1 + f 1 y |
Instances
Show Declaration Source # | |
Defined in Parser.Ast showsPrec :: Int -> Declaration -> ShowS # show :: Declaration -> String # showList :: [Declaration] -> ShowS # | |
Eq Declaration Source # | |
Defined in Parser.Ast (==) :: Declaration -> Declaration -> Bool # (/=) :: Declaration -> Declaration -> Bool # |
Expressions
data Expression Source #
Expression.
ExprId Identifier | Identifier expression, see |
ExprPrimVal PrimitiveValue | Primitive value expression, see |
ExprBinOp BinaryOperator Expression Expression | Binary operation, see |
ExprUnOp UnaryOperator Expression | Unary operation, see |
ExprApp Expression Expression | Function application expression. f 6 (fun x y = x + y) 5 |
ExprIte Expression Expression Expression | If-then-else expression. if x > 4 then x * 8 else x / 15 |
ExprLetIn Declaration Expression | Let expression. let x = 4 in x * x let f x y = x + y in f 4 8 let rec f x y = f x 1 + f 1 y in f 4 8 |
ExprFun Fun | Anonymous function, see |
Instances
Show Expression Source # | |
Defined in Parser.Ast showsPrec :: Int -> Expression -> ShowS # show :: Expression -> String # showList :: [Expression] -> ShowS # | |
Eq Expression Source # | |
Defined in Parser.Ast (==) :: Expression -> Expression -> Bool # (/=) :: Expression -> Expression -> Bool # |
Function representation without the name.
It contains its parameters, returned type and body.
fun x -> true
fun x y -> x + y
Fun (NonEmpty (Identifier, Maybe Type)) (Maybe Type) Expression |