diff options
author | Erik Oosting | 2023-12-18 18:58:35 +0100 |
---|---|---|
committer | Erik Oosting | 2023-12-18 18:58:35 +0100 |
commit | 03eb5c1228ea9f5997fc19f7075a90cca1d29820 (patch) | |
tree | e49cc06de0417120aea1f26b39fbf0913e534d12 /haskell/app/Types.hs | |
parent | daf044b576feb8ee61bb6be18f28985f5e87f4f4 (diff) |
add free variable searching
Diffstat (limited to 'haskell/app/Types.hs')
-rw-r--r-- | haskell/app/Types.hs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/haskell/app/Types.hs b/haskell/app/Types.hs new file mode 100644 index 0000000..8c4790f --- /dev/null +++ b/haskell/app/Types.hs @@ -0,0 +1,64 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} + +module Types where + +import Data.Functor.Foldable.TH +import GHC.Generics + +data AExp + = LitTrue + | LitFalse + | Ident String + | Number Integer + | LitStr String + | AAdd AExp AExp + | ASub AExp AExp + | AMul AExp AExp + | ADiv AExp AExp + | AGt AExp AExp + | ALt AExp AExp + | AEq AExp AExp + | ABsl AExp AExp + | ABsr AExp AExp + | AAnd AExp AExp + | AOr AExp AExp + | AXor AExp AExp + | Lam [String] CExp + deriving (Show, Read, Generic) + +data GlobalAExp + = GlobalLitTrue + | GlobalLitFalse + | GlobalIdent String + | GlobalNumber Integer + | GlobalLitStr String + | GlobalAAdd GlobalAExp GlobalAExp + | GlobalASub GlobalAExp GlobalAExp + | GlobalAMul GlobalAExp GlobalAExp + | GlobalADiv GlobalAExp GlobalAExp + | GlobalAGt GlobalAExp GlobalAExp + | GlobalALt GlobalAExp GlobalAExp + | GlobalAEq GlobalAExp GlobalAExp + | GlobalABsl GlobalAExp GlobalAExp + | GlobalABsr GlobalAExp GlobalAExp + | GlobalAAnd GlobalAExp GlobalAExp + | GlobalAOr GlobalAExp GlobalAExp + | GlobalAXor GlobalAExp GlobalAExp + | Funcref String + deriving (Show, Read, Generic) +data Funcall + = Call String [AExp] + | Atom AExp + deriving (Show, Read, Generic) + +data CExp + = Let String Funcall CExp + | If AExp CExp CExp + | FC Funcall + deriving (Show, Read, Generic) + +makeBaseFunctor ''CExp +makeBaseFunctor ''AExp +makeBaseFunctor ''GlobalAExp +makeBaseFunctor ''Funcall |