Safe Haskell | Safe-Inferred |
---|
Syntax
Description
Abstract Syntax Tree (AST) definitions for the simple functional language.
Documentation
A program is simply a list of declarations (functions).
A top-level declaration consists of a function name, its parameters, and its body expression.
Expressions in the language.
Constructors
Var Ident | Variable reference |
Lit Literal | Literal constant |
Lambda [Ident] Expr | Lambda abstraction with parameters and body |
If Expr Expr Expr | |
Case Expr [(Pattern, Expr)] | Pattern matching: case expr of alternatives |
Let [Decl] Expr | Local declarations and body expression |
App Expr Expr | Function application |
BinOp BinOperator Expr Expr | Binary operator application |
UnOp UnOperator Expr | Unary operator application |
List [Expr] | List literal |
Tuple [Expr] | Tuple literal |
Patterns used in case alternatives.
Literal values supported by the language.
data BinOperator Source #
Binary operators.
Constructors
Add | Addition (+) |
Sub | Subtraction (-) |
Mul | Multiplication (*) |
Div | Division (/) |
Mod | Modulus (mod) |
Eq | Equality (==) |
Neq | Inequality (/=) |
Lt | Less than (<) |
Le | Less than or equal (<=) |
Gt | Greater than (>) |
Ge | Greater than or equal (>=) |
And | Logical and (&&) |
Or | Logical or (||) |
Instances
Show BinOperator Source # | |
Defined in Syntax Methods showsPrec :: Int -> BinOperator -> ShowS show :: BinOperator -> String showList :: [BinOperator] -> ShowS |
data UnOperator Source #
Unary operators.
Instances
Show UnOperator Source # | |
Defined in Syntax Methods showsPrec :: Int -> UnOperator -> ShowS show :: UnOperator -> String showList :: [UnOperator] -> ShowS |