From 34d9f21c6ab529e415f38a5a886b1b612bcbd3bc Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 10 Mar 2019 00:13:32 +0100 Subject: Initial --- src/Haskell/AST.hs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Haskell/AST.hs (limited to 'src/Haskell/AST.hs') 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) -- cgit v1.2.3-70-g09d2