Types.hs (1608B)
1 {-# LANGUAGE TemplateHaskell #-} 2 {-# LANGUAGE TypeFamilies #-} 3 4 module Types ( 5 AExp (..), 6 GlobalAExp (..), 7 CExp (..), 8 Funcall (..), 9 AExpF (..), 10 GlobalAExpF (..), 11 CExpF (..), 12 ) where 13 14 import Data.Functor.Foldable.TH 15 import GHC.Generics 16 17 data AExp 18 = LitTrue 19 | LitFalse 20 | Ident String 21 | Number Integer 22 | LitStr String 23 | AAdd AExp AExp 24 | ASub AExp AExp 25 | AMul AExp AExp 26 | ADiv AExp AExp 27 | AGt AExp AExp 28 | ALt AExp AExp 29 | AEq AExp AExp 30 | ABsl AExp AExp 31 | ABsr AExp AExp 32 | AAnd AExp AExp 33 | AOr AExp AExp 34 | AXor AExp AExp 35 | Lam [String] CExp 36 deriving (Show, Read, Generic) 37 38 data GlobalAExp 39 = GlobalLitTrue 40 | GlobalLitFalse 41 | GlobalIdent String 42 | GlobalNumber Integer 43 | GlobalLitStr String 44 | GlobalAAdd GlobalAExp GlobalAExp 45 | GlobalASub GlobalAExp GlobalAExp 46 | GlobalAMul GlobalAExp GlobalAExp 47 | GlobalADiv GlobalAExp GlobalAExp 48 | GlobalAGt GlobalAExp GlobalAExp 49 | GlobalALt GlobalAExp GlobalAExp 50 | GlobalAEq GlobalAExp GlobalAExp 51 | GlobalABsl GlobalAExp GlobalAExp 52 | GlobalABsr GlobalAExp GlobalAExp 53 | GlobalAAnd GlobalAExp GlobalAExp 54 | GlobalAOr GlobalAExp GlobalAExp 55 | GlobalAXor GlobalAExp GlobalAExp 56 | Funcref String 57 deriving (Show, Read, Generic) 58 data Funcall 59 = Call String [AExp] 60 | Atom AExp 61 deriving (Show, Read, Generic) 62 63 data CExp 64 = Let String Funcall CExp 65 | If AExp CExp CExp 66 | FC Funcall 67 deriving (Show, Read, Generic) 68 69 makeBaseFunctor ''CExp 70 makeBaseFunctor ''AExp 71 makeBaseFunctor ''GlobalAExp