From 0c815fa3eb480ae5e05370699cead004d81cf65c Mon Sep 17 00:00:00 2001 From: Paweł Dybiec Date: Sun, 19 Jan 2020 22:59:54 +0100 Subject: Add Except monad, and destructors for records and variants --- src/Syntax.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Syntax.hs') diff --git a/src/Syntax.hs b/src/Syntax.hs index c33f7b3..bbd8cbe 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -3,10 +3,11 @@ module Syntax type Idnt = String data Typ = TInt - | TRecord [(Idnt, Typ)] - | TVariant [(Idnt, Typ)] + | TRecord TypeDict + | TVariant TypeDict | TPtr Typ deriving(Eq,Show) +type TypeDict = [(Idnt,Typ)] data Expr = Var Idnt | IntLit Int @@ -16,6 +17,8 @@ data Expr = Var Idnt | Mult Expr Expr | Neg Expr | Deref Expr + | Match Expr [(Idnt, Expr)] + | Proj Idnt Expr deriving(Eq,Show) data Com = Skip | Seq Com Com @@ -25,6 +28,7 @@ data Com = Skip | Decl Idnt Expr Com | Alloc Idnt Expr | Save Idnt Expr + | SMatch Expr [(Idnt, Expr)] deriving(Eq,Show) data FuncDecl = Func Idnt [Idnt] [(Idnt,Expr)] Com Expr -- cgit 1.4.1