| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Interpreter.Result
Synopsis
- type Result s a = ExceptT Err (StateT (Env s) (ST s)) a
- lift2 :: ST s a -> Result s a
- type ResultValue = Either Err
- data Err
- data Env s = Env {
- _funcs :: Map Identifier (STRef s Function, Scope s)
- _funcScopes :: [FuncScope s]
- _accumulatedOutput :: AccOut
- type AccOut = [Text]
- emptyEnv :: Env s
- newtype FuncScope s = FuncScope {}
- newtype Scope s = Scope {
- _vars :: Map Identifier (STRef s (RuntimeValue s))
- emptyScope :: Scope s
- data RuntimeValue s
- = ValInt Int
- | ValBool Bool
- | ValString Text
- | ValArray [RuntimeValue s]
- | ValFunction FunctionValue (Scope s)
- funcs :: forall s. Lens' (Env s) (Map Identifier (STRef s Function, Scope s))
- funcScopes :: forall s. Lens' (Env s) [FuncScope s]
- accumulatedOutput :: forall s. Lens' (Env s) AccOut
- scopes :: forall s s. Iso (FuncScope s) (FuncScope s) [Scope s] [Scope s]
- vars :: forall s s. Iso (Scope s) (Scope s) (Map Identifier (STRef s (RuntimeValue s))) (Map Identifier (STRef s (RuntimeValue s)))
- var :: Applicative f => Int -> Int -> Identifier -> LensLike' f (Env s) (Maybe (STRef s (RuntimeValue s)))
- data Env' = Env' {}
- evalEnv :: Env s -> ST s Env'
- newtype FuncScope' = FuncScope' {}
- evalFuncScope :: FuncScope s -> ST s FuncScope'
- newtype Scope' = Scope' {}
- evalScope :: Scope s -> ST s Scope'
- data RuntimeValue'
- evalRuntimeValue :: RuntimeValue s -> RuntimeValue'
- unevalRuntimeValue :: RuntimeValue' -> RuntimeValue s
- funcs' :: Lens' Env' (Map Identifier Function)
- funcScopes' :: Lens' Env' [FuncScope']
- accumulatedOutput' :: Lens' Env' AccOut
- scopes' :: Iso' FuncScope' [Scope']
- vars' :: Iso' Scope' (Map Identifier RuntimeValue')
Interpretation result
type Result s a = ExceptT Err (StateT (Env s) (ST s)) a Source #
Represents the result of interpretation.
Result value
type ResultValue = Either Err Source #
Represents unsuccessful interpretation.
Constructors
| DivisionByZero | Division by zero error. |
| IndexOutOfRange Int Int | Index out of bounds error, contains info about index and array length. |
| NoReturn | No return error. |
| Npe | Null dereference error (happens when trying to call the |
| Panic Text | Panic error (happens when calling |
| UnexpectedError | Unexpected error, this type of errors must never happen. |
State
Environment
Constructors
| Env | |
Fields
| |
Function scope
Scope
Scope contains identifiers mapped to their types.
Constructors
| Scope | |
Fields
| |
emptyScope :: Scope s Source #
Create empty Scope.
Runtime value
data RuntimeValue s Source #
Represents runtime value of the calculated expression.
Constructors
| ValInt Int | Int value. |
| ValBool Bool | Boolean value. |
| ValString Text | String value. |
| ValArray [RuntimeValue s] | Array value. |
| ValFunction FunctionValue (Scope s) | Function value. |
Instances
| Eq (RuntimeValue s) Source # | |
Defined in Interpreter.Result Methods (==) :: RuntimeValue s -> RuntimeValue s -> Bool # (/=) :: RuntimeValue s -> RuntimeValue s -> Bool # | |
Optics
vars :: forall s s. Iso (Scope s) (Scope s) (Map Identifier (STRef s (RuntimeValue s))) (Map Identifier (STRef s (RuntimeValue s))) Source #
var :: Applicative f => Int -> Int -> Identifier -> LensLike' f (Env s) (Maybe (STRef s (RuntimeValue s))) Source #
Evaluated state
Environment
Constructors
| Env' | |
Fields | |
Function scope
newtype FuncScope' Source #
Constructors
| FuncScope' | |
Instances
| Show FuncScope' Source # | |
Defined in Interpreter.Result Methods showsPrec :: Int -> FuncScope' -> ShowS # show :: FuncScope' -> String # showList :: [FuncScope'] -> ShowS # | |
evalFuncScope :: FuncScope s -> ST s FuncScope' Source #
Scope
Constructors
| Scope' | |
Fields | |
Runtime value
data RuntimeValue' Source #
Represents runtime value of the calculated expression.
Constructors
| ValInt' Int | Int value. |
| ValBool' Bool | Boolean value. |
| ValString' Text | String value. |
| ValArray' [RuntimeValue'] | Array value. |
| ValFunction' FunctionValue | Function value. |
Instances
| Show RuntimeValue' Source # | |
Defined in Interpreter.Result Methods showsPrec :: Int -> RuntimeValue' -> ShowS # show :: RuntimeValue' -> String # showList :: [RuntimeValue'] -> ShowS # | |
evalRuntimeValue :: RuntimeValue s -> RuntimeValue' Source #
Optics
funcScopes' :: Lens' Env' [FuncScope'] Source #
vars' :: Iso' Scope' (Map Identifier RuntimeValue') Source #