blob: 0b986182f971d1730f962c8328b7ca4dd54a63f5 (
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
|
module AST where
data Program t = Program [FunDef t]
deriving (Show)
data FunDef t = FunDef Name (Maybe Type) [FunEq t]
deriving (Show)
newtype Name = Name String
deriving (Show, Eq)
data Type
= TApp Type [Type]
| TTup [Type]
| TList Type
| TFun Type Type
| TCon Name
| TVar Name
deriving (Show)
data FunEq t = FunEq Name [Pattern t] (RHS t)
deriving (Show)
data Pattern t
= PWildcard t
| PVar t Name
| PAs t Name (Pattern t)
| PCon t Name [Pattern t]
| PList t [Pattern t]
| PTup t [Pattern t]
deriving (Show)
data RHS t
= Guarded [(Expr t, Expr t)]
| Plain (Expr t)
deriving (Show)
data Expr t
= ELit t Literal
| EList t [Expr t]
| ETup t [Expr t]
| EApp t (Expr t) (Expr t)
| EOp t (Expr t) Operator (Expr t)
| EIf t (Expr t) (Expr t) (Expr t)
| ECase t (Expr t) [(Pattern t, RHS t)]
| ELet t [FunDef t] (Expr t)
deriving (Show)
data Literal = LInt Int | LFloat Double | LChar Char | LString String
deriving (Show)
data Operator = OAdd | OSub | OMul | ODiv | OMod
deriving (Show)
|