summary refs log tree commit diff
path: root/haskell/app/Types.hs
blob: 3f57bb9fd609279ef1810528b59f52b7165616f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Types (
    AExp (..),
    GlobalAExp (..),
    CExp (..),
    Funcall (..),
    AExpF (..),
    GlobalAExpF (..),
    CExpF (..),
) 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