[SOLVED] CS代考 module MinHS.Syntax where

30 $

File Name: CS代考_module_MinHS.Syntax_where.zip
File Size: 320.28 KB

SKU: 1085512104 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


module MinHS.Syntax where

import Data.List

Copyright By PowCoder代写加微信 assignmentchef

type Id = String

type Program = [Bind]

| Num Integer
| App Exp Exp
| If Exp Exp Exp
| Let [Bind] Exp
| Recfun Bind
| Letrec [Bind] Exp
| Case Exp [Alt]
deriving (Read,Show,Eq)

data Alt = Alt Id [Id] Exp
deriving (Read,Show,Eq)

data Bind = Bind Id (Maybe QType) [Id] Exp
deriving (Read,Show,Eq)

data Op = Add
deriving (Show, Eq, Read)

data QType = Forall Id QType
deriving (Read, Show, Eq, Ord)

data Type = Arrow Type Type
| Prod Type Type
| Sum Type Type
| Base BaseType
| TypeVar Id
deriving (Read, Show, Eq, Ord)

data BaseType = Unit
deriving (Read, Show, Eq, Ord)

binApply :: Exp -> Exp -> Exp -> Exp
binApply e1 e2 e3 = App (App e1 e2) e3

allTypes :: (QType -> QType) -> Exp -> Exp
allTypes f (App e1 e2) = App (allTypes f e1) (allTypes f e2)
allTypes f (If c t e)= If (allTypes f c) (allTypes f t) (allTypes f e)
allTypes f (Let bs e)= Let (map (allTypesBind f) bs) (allTypes f e)
allTypes f (Recfun b)= Recfun (allTypesBind f b)
allTypes f (Letrec bs e)= Letrec (map (allTypesBind f) bs) (allTypes f e)
allTypes f (Case e alts)= Case (allTypes f e) (map (allTypesAlt f) alts)
allTypes f x = x

allTypesBind f (Bind n ty xs e) = Bind n (fmap f ty) xs (allTypes f e)

allTypesAlt f (Alt t ps e) = Alt t ps (allTypes f e)

程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代考 module MinHS.Syntax where
30 $