import Control.Monad
AST and Type Definitions
data TYPELANG = TNum
deriving (Show, Eq)
Copyright By PowCoder代写 加微信 powcoder
data TERMLANG = Num Int
Plus TERMLANG TERMLANG
Minus TERMLANG TERMLANG
Mult TERMLANG TERMLANG
Div TERMLANG TERMLANG
Boolean Bool
And TERMLANG TERMLANG
Or TERMLANG TERMLANG
Leq TERMLANG TERMLANG
IsZero TERMLANG
If TERMLANG TERMLANG TERMLANG
Bind String TERMLANG TERMLANG
I Id String
deriving (Show, Eq)
type Env = [(String, TERMLANG)]
type Cont = [ (String, TYPELANG)]
Project Exercises
– Part 1: Adding Booleans
— Exercise 1
evalS :: TERMLANG -› (Maybe TERMLANG)
— Exercise 2
eval :: Env
-› TERMLANG -› (Maybe TERMLANG)
Exercise 3
testEvals:: TERMLANG -> Bool
Part 2: Type Checking
–Exercise 1
typeofM :: Cont -› TERMLANG -> (Mavbe TYPELANG)
–Exercise
evalT :: TERMLANG -› (Mavbe TERMLANG)
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com