mini-go-0.3.0.0: Mini Go parser and interpreter
Safe HaskellSafe-Inferred
LanguageHaskell2010

Interpreter.Result

Synopsis

Interpretation result

type Result s a = ExceptT Err (StateT (Env s) (ST s)) a Source #

Represents the result of interpretation.

lift2 :: ST s a -> Result s a Source #

Result value

data 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 nil as a regular function).

Panic Text

Panic error (happens when calling panic stdlib function).

UnexpectedError

Unexpected error, this type of errors must never happen.

Instances

Instances details
Show Err Source # 
Instance details

Defined in Interpreter.Result

Methods

showsPrec :: Int -> Err -> ShowS #

show :: Err -> String #

showList :: [Err] -> ShowS #

State

Environment

type AccOut = [Text] Source #

Accumulated output (every element is a text printed to the stdout).

Function scope

newtype FuncScope s Source #

Constructors

FuncScope 

Fields

Scope

newtype Scope s Source #

Scope contains identifiers mapped to their types.

Constructors

Scope 

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

Instances details
Eq (RuntimeValue s) Source # 
Instance details

Defined in Interpreter.Result

Optics

funcs :: forall s. Lens' (Env s) (Map Identifier (STRef s Function, Scope s)) Source #

funcScopes :: forall s. Lens' (Env s) [FuncScope s] Source #

scopes :: forall s s. Iso (FuncScope s) (FuncScope s) [Scope s] [Scope s] Source #

vars :: forall s s. Iso (Scope s) (Scope s) (Map Identifier (STRef s (RuntimeValue s))) (Map Identifier (STRef s (RuntimeValue s))) Source #

Evaluated state

Environment

data Env' Source #

Instances

Instances details
Show Env' Source # 
Instance details

Defined in Interpreter.Result

Methods

showsPrec :: Int -> Env' -> ShowS #

show :: Env' -> String #

showList :: [Env'] -> ShowS #

Function scope

newtype FuncScope' Source #

Constructors

FuncScope' 

Fields

Instances

Instances details
Show FuncScope' Source # 
Instance details

Defined in Interpreter.Result

Scope

newtype Scope' Source #

Constructors

Scope' 

Instances

Instances details
Show Scope' Source # 
Instance details

Defined in Interpreter.Result

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

Instances details
Show RuntimeValue' Source # 
Instance details

Defined in Interpreter.Result

Optics