|
|
|
|
|
Description |
Haskell types related to Gulik.
|
|
Synopsis |
|
|
|
|
Basic types
|
|
data Expr |
Algebraic data type for Gulik expressions.
| Constructors | ExprDouble | A double-valued literal.
| | ExprInteger | An integer-valued literal.
| | ExprString | A string-valued literal.
| | ExprApply | An application.
| ExprName | A name.
| | ExprBind | A bind to a name.
| | ExprBody | A body (list of expressions in {...}).
| |
| Instances | |
|
|
type Env = Map String Value |
An environment, mapping names to values.
|
|
data Value |
Algebraic data type for Gulik run-time values.
| Constructors | ValueDouble | A double value
| valueDouble :: Double | Extract the double.
|
| ValueInteger | An integer value.
| valueInteger :: Integer | Extract the integer.
|
| ValueBool | A Boolean value.
| valueBool :: Bool | Extract the Boolean.
|
| ValueString | A string value.
| valueString :: String | Extract the string.
|
| ValueNil | A nil pair.
| ValuePair | A (non-nil) pair.
| valueCar :: Value | The car of the pair.
| valueCdr :: Value | The cdr of the pair.
|
| ValueClosure | A function closure, written in Gulik.
| valueEnv :: Env | The environment for the closure.
| valueBody :: [Expr] | The body of the closure.
|
| ValueBuiltin | A function closure, written in Haskell.
| valueBuiltin :: (Interp ()) | The Interp monad action for the builtin.
| valueBuiltinName :: String | The name of the builtin (used for superficial things).
|
|
| Instances | |
|
|
Interp monad and error handling
|
|
type Interp = StateT InterpState (Either InterpError) |
Monad for the stack machine operations, combining state and error handling.
|
|
data InterpState |
State of the interpreter stack machine.
| Constructors | InterpState | | stateStack :: [Value] | Current stack.
| stateEnv :: Env | Current environment.
|
|
| Instances | |
|
|
data InterpError |
Errors thrown by the stack machine.
| Constructors | UndefinedSymbol | A symbol was accessed before being defined.
| errorSymbolName :: String | Name of the undefined symbol.
|
| StackUnderflow | A pop was executed on an empty stack.
| InvalidApply | A non-closure was applied.
| errorApplyValue :: Value | Value for which apply was attempted.
|
| BuiltinTypeError | A builtin function was applied with bad types.
| errorBuiltinName :: String | The name of the builtin applied.
|
| UserError | A user-defined error occurred.
| errorUserString :: String | A string describing the error.
|
| UnknownError | An unknown error occurred.
|
| Instances | |
|
|
Produced by Haddock version 0.7 |