aboutsummaryrefslogtreecommitdiff
path: root/src/Haskell/AST.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-03-10 00:13:32 +0100
committertomsmeding <tom.smeding@gmail.com>2019-03-10 00:13:32 +0100
commit34d9f21c6ab529e415f38a5a886b1b612bcbd3bc (patch)
tree15a7f35385515b7bc65a3cc5c84249533e1c62c3 /src/Haskell/AST.hs
Initial
Diffstat (limited to 'src/Haskell/AST.hs')
-rw-r--r--src/Haskell/AST.hs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Haskell/AST.hs b/src/Haskell/AST.hs
new file mode 100644
index 0000000..8326440
--- /dev/null
+++ b/src/Haskell/AST.hs
@@ -0,0 +1,52 @@
+module Haskell.AST where
+
+
+type Name = String
+type TyVar = String
+
+data AST = AST [Toplevel]
+ deriving (Show)
+
+data Toplevel = TopDef Def
+ | TopDecl Decl
+ | TopData Data
+ | TopClass Class
+ | TopInst Inst
+ deriving (Show)
+
+data Def = Def Name Expr
+ deriving (Show)
+
+data Expr = App Expr [Expr]
+ | Ref Name
+ | LitNum Integer
+ | Tup [Expr]
+ | Lam [Name] Expr
+ | Case Name [(Pat, Expr)]
+ deriving (Show)
+
+data Pat = PatAny
+ | PatVar Name
+ | PatCon Name [Pat]
+ | PatTup [Pat]
+ deriving (Show)
+
+data Decl = Decl Name Type
+ deriving (Show)
+
+data Type = TyTup [Type]
+ | TyInt
+ | TyFun Type Type
+ | TyRef Name [Type]
+ | TyVar Name
+ | TyVoid
+ deriving (Show)
+
+data Data = Data Name [TyVar] [(Name, [Type])]
+ deriving (Show)
+
+data Class = Class Name [TyVar] [Decl]
+ deriving (Show)
+
+data Inst = Inst Name Type [Def]
+ deriving (Show)