Be sure you put your name and e-mail in a comment at the beginning of the file. Without this you will not get any feedback.
In this homework you will write several interpreters for a simple language with assignments. You will do this with and without the use of monads.
The language we are interested in has the following abstract syntax. This is a variation of the languages we used as examples in the lecture on monadic interpreters (the haskell code is here).
-- A language with variables and assignments data T5 = Add5 T5 T5 | Sub5 T5 T5 | Mult5 T5 T5 | Int5 Int | Var5 String | Assign5 String T5
getStore :: String -> (Store Map Value)
Given a name "x", and a new value "v" "putStore x v" returns a Store computation, that when run, returns unit, but updates the map so "x" is now mapped to "v"
putStore :: String -> Value -> (Store Map ())
The Monad instance for the Store monad is given below.
data Store s x = St(s -> (x,s)) type Map = [(String,Value)] instance Monad (Store s) where return x = St(\ s -> (x,s)) (>>=) (St f) g = St h where h s1 = g' s2 where (x,s2) = f s1 St g' = g x