scratch-clone-2022.0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Interpreter

Synopsis

Documentation

type Memory = [(String, Int)] Source #

In our memory, named locations map to values.

data Err Source #

Enumerates reasons for errors.

Constructors

DivByZeroError

Division by zero was attempted.

NegativeExponentError

Raising a number to a negative exponent was attempted.

UninitialisedMemory String

Tried to read from a variable that does not exist.

Instances

Instances details
Eq Err Source # 
Instance details

Defined in Interpreter

Methods

(==) :: Err -> Err -> Bool #

(/=) :: Err -> Err -> Bool #

Show Err Source # 
Instance details

Defined in Interpreter

Methods

showsPrec :: Int -> Err -> ShowS #

show :: Err -> String #

showList :: [Err] -> ShowS #

interpret :: Program -> Memory -> Either Err Memory Source #

Given a program and the initial memory contents, determines what evaluating the program does to the memory.