Safe Haskell | None |
---|
Data types for values, statements, binders and do notation
- type Guard = Value
- data UnaryOperator
- = Negate
- | Not
- | BitwiseNot
- | Positive
- data BinaryOperator
- = Add
- | Subtract
- | Multiply
- | Divide
- | Modulus
- | EqualTo
- | NotEqualTo
- | LessThan
- | LessThanOrEqualTo
- | GreaterThan
- | GreaterThanOrEqualTo
- | And
- | Or
- | BitwiseAnd
- | BitwiseOr
- | BitwiseXor
- | ShiftLeft
- | ShiftRight
- | ZeroFillShiftRight
- | Concat
- data Value
- = NumericLiteral (Either Integer Double)
- | StringLiteral String
- | BooleanLiteral Bool
- | Unary UnaryOperator Value
- | Binary BinaryOperator Value Value
- | BinaryNoParens (Qualified Ident) Value Value
- | Parens Value
- | ArrayLiteral [Value]
- | Indexer Value Value
- | ObjectLiteral [(String, Value)]
- | Accessor String Value
- | ObjectUpdate Value [(String, Value)]
- | Abs [Ident] Value
- | App Value [Value]
- | Var (Qualified Ident)
- | IfThenElse Value Value Value
- | Block [Statement]
- | Constructor (Qualified ProperName)
- | Case [Value] [([Binder], Maybe Guard, Value)]
- | TypedValue Bool Value Type
- | Do [DoNotationElement]
- | TypeClassDictionary (Qualified ProperName, Type) [TypeClassDictionaryInScope]
- data TypeClassDictionaryType
- = TCDRegular
- | TCDAlias (Qualified Ident)
- data TypeClassDictionaryInScope = TypeClassDictionaryInScope {}
- data DoNotationElement
- data Statement
- data IfStatement = IfStatement Value [Statement] (Maybe ElseStatement)
- data ElseStatement
- = Else [Statement]
- | ElseIf IfStatement
- data Binder
- = NullBinder
- | BooleanBinder Bool
- | StringBinder String
- | NumberBinder (Either Integer Double)
- | VarBinder Ident
- | NullaryBinder (Qualified ProperName)
- | UnaryBinder (Qualified ProperName) Binder
- | ObjectBinder [(String, Binder)]
- | ArrayBinder [Binder]
- | ConsBinder Binder Binder
- | NamedBinder Ident Binder
Documentation
A guard is just a boolean-valued expression that appears alongside a set of binders
data UnaryOperator Source
Built-in unary operators
Negate | Numeric negation |
Not | Boolean negation |
BitwiseNot | Bitwise negation |
Positive | Numeric unary 'plus' |
data BinaryOperator Source
Built-in binary operators
Add | Numeric addition |
Subtract | Numeric subtraction |
Multiply | Numeric multiplication |
Divide | Numeric division |
Modulus | Remainder |
EqualTo | Generic equality test |
NotEqualTo | Generic inequality test |
LessThan | Numeric less-than |
LessThanOrEqualTo | Numeric less-than-or-equal |
GreaterThan | Numeric greater-than |
GreaterThanOrEqualTo | Numeric greater-than-or-equal |
And | Boolean and |
Or | Boolean or |
BitwiseAnd | Bitwise and |
BitwiseOr | Bitwise or |
BitwiseXor | Bitwise xor |
ShiftLeft | Bitwise left shift |
ShiftRight | Bitwise right shift |
ZeroFillShiftRight | Bitwise right shift with zero-fill |
Concat | String concatenation |
Data type for values
NumericLiteral (Either Integer Double) | A numeric literal |
StringLiteral String | A string literal |
BooleanLiteral Bool | A boolean literal |
Unary UnaryOperator Value | Unary operator application |
Binary BinaryOperator Value Value | Binary operator application |
BinaryNoParens (Qualified Ident) Value Value | Binary operator application. During the rebracketing phase of desugaring, this data constructor will be removed. |
Parens Value | Explicit parentheses. During the rebracketing phase of desugaring, this data constructor will be removed. |
ArrayLiteral [Value] | An array literal |
Indexer Value Value | An array indexing expression |
ObjectLiteral [(String, Value)] | An object literal |
Accessor String Value | An record property accessor expression |
ObjectUpdate Value [(String, Value)] | Partial record update |
Abs [Ident] Value | Function introduction |
App Value [Value] | Function application |
Var (Qualified Ident) | Variable |
IfThenElse Value Value Value | Conditional (if-then-else expression) |
Block [Statement] | A "Block" i.e. a collection of statements which evaluate to a value |
Constructor (Qualified ProperName) | A data constructor |
Case [Value] [([Binder], Maybe Guard, Value)] | A case expression. During the case expansion phase of desugaring, top-level binders will get desugared into case expressions, hence the need for guards and multiple binders per branch here. |
TypedValue Bool Value Type | A value with a type annotation |
Do [DoNotationElement] | A do-notation block |
TypeClassDictionary (Qualified ProperName, Type) [TypeClassDictionaryInScope] | A placeholder for a type class dictionary to be inserted later. At the end of type checking, these placeholders will be replaced with actual expressions representing type classes dictionaries which can be evaluated at runtime. The constructor arguments represent (in order): the type class name and instance type, and the type class dictionaries in scope. |
data TypeClassDictionaryType Source
The type of a type class dictionary
TCDRegular | A regular type class dictionary |
TCDAlias (Qualified Ident) | A type class dictionary which is an alias for an imported dictionary from another module |
data TypeClassDictionaryInScope Source
Data representing a type class dictionary which is in scope
TypeClassDictionaryInScope | |
|
data DoNotationElement Source
A statement in a do-notation block
DoNotationValue Value | A monadic value without a binder |
DoNotationBind Binder Value | A monadic value with a binder |
DoNotationLet Binder Value | A let statement, i.e. a pure value with a binder |
Data type for statements which can appear inside a Block
expression
data IfStatement Source
Data type for if-statements
IfStatement Value [Statement] (Maybe ElseStatement) | An if statement. Arguments are (in order): boolean condition, true branch, optional else branch. |
data ElseStatement Source
Data type for the else branch in an if-statement
Else [Statement] | An else branch |
ElseIf IfStatement | An else-if branch |
Data type for binders
NullBinder | Wildcard binder |
BooleanBinder Bool | A binder which matches a boolean literal |
StringBinder String | A binder which matches a string literal |
NumberBinder (Either Integer Double) | A binder which matches a numeric literal |
VarBinder Ident | A binder which binds an identifier |
NullaryBinder (Qualified ProperName) | A binder which matches a data constructor with no argument |
UnaryBinder (Qualified ProperName) Binder | A binder which matches a data constructor with one argument |
ObjectBinder [(String, Binder)] | A binder which matches a record and binds its properties |
ArrayBinder [Binder] | A binder which matches an array and binds its elements |
ConsBinder Binder Binder | A binder which matches an array and binds its head and tail |
NamedBinder Ident Binder | A binder which binds its input to an identifier |