Safe Haskell | Safe |
---|
- type VarName = String
- data Expr
- data Value
- data Op
- data Ty
- printParens :: Bool -> Doc -> Doc
- (<+..>) :: Doc -> Doc -> Doc
- (<+....>) :: Doc -> Doc -> Doc
- printTyPrec :: Int -> Ty -> Doc
- printExprPrec :: Int -> Expr -> Doc
- printValuePrec :: Int -> Value -> Doc
- printExpr :: Expr -> Doc
- printValue :: Value -> Doc
- printTy :: Ty -> Doc
Documentation
Moses expressions
NOTE: In the comments below, concrete Moses syntax examples are shown between braces. For example, { f 42 } is Moses concrete syntax for calling the function { f } and passing the argument { 42 }.
Exactly Value | value (doesn't need evaluation) For example:
{ 1 } is represented as |
Var VarName | variable For example:
{ x } is represented as |
Apply Expr Expr | function application For example:
{ f 42 } is represented as |
BinOp Op Expr Expr | built-in operator For example:
{ 2+2 } is represented as For example:
{ x @ [] } is represented as |
If Expr Expr Expr | if statement For example:
{ if a then b else c } is represented as |
Let [VarName] Expr Expr | let statement, handles both regular lets and tuple-match lets For example:
{ let x = 2 in x + x } is represented as
For example:
{ let (x,y) = mypair in x+y } is represented as
|
LetRec VarName Expr Expr | recursive let statement For example:
{ letrec ones = 1 : ones in ones } is represented as
|
Lambda VarName Ty Expr | lambda expression For example:
{ x :: INT -> x + 1 } is represented as
|
ListCase Expr Expr VarName VarName Expr | case expression on lists For example:
{ case l of [] -> 0
| h : t -> h } is represented as
Notice that the form is very restrictive; you cannot have case expressions where the patterns have a different structure. It must be empty list as the first case and head and tail as the second! |
Tuple [Expr] | expression to create a tuple For example:
{ (x,1,[]) } is represented as
|
Literal values
Operators
Built-in types
printParens :: Bool -> Doc -> Doc #
printTyPrec :: Int -> Ty -> Doc #
printExprPrec :: Int -> Expr -> Doc #
Printing expressions
printValuePrec :: Int -> Value -> Doc #
printValue :: Value -> Doc #