From a9134688a2132c8f9abfff206f6e30614bb9aeff Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 23 Jul 2020 20:16:39 +0200 Subject: WIP lambdas --- ast/CC/Typed.hs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'ast/CC/Typed.hs') diff --git a/ast/CC/Typed.hs b/ast/CC/Typed.hs index 5b8ed38..535fd31 100644 --- a/ast/CC/Typed.hs +++ b/ast/CC/Typed.hs @@ -7,13 +7,10 @@ import CC.Pretty import CC.Types -data ProgramT = ProgramT [DeclT] +data ProgramT = ProgramT [DefT] deriving (Show, Read) -data DeclT = DefT DefT -- import? - deriving (Show, Read) - -data DefT = FunctionT TypeT Name [Name] ExprT +data DefT = DefT Name ExprT deriving (Show, Read) data TypeT = TFunT TypeT TypeT @@ -21,16 +18,17 @@ data TypeT = TFunT TypeT TypeT | TyVar Int deriving (Show, Read) -data ExprT = CallT TypeT ExprT ExprT +data ExprT = LamT TypeT Occ ExprT + | CallT TypeT ExprT ExprT | IntT Int | VarT Occ deriving (Show, Read) --- | Occurrence of a variable data Occ = Occ Name TypeT deriving (Show, Read) exprType :: ExprT -> TypeT +exprType (LamT typ _ _) = typ exprType (CallT typ _ _) = typ exprType (IntT _) = TIntT exprType (VarT (Occ _ typ)) = typ @@ -55,10 +53,7 @@ instance Pretty ExprT where show n ++ " :: " ++ pretty t instance Pretty DefT where - pretty (FunctionT n e) = n ++ " = " ++ pretty e - -instance Pretty DeclT where - pretty (DefT def) = pretty def + pretty (DefT n e) = n ++ " = " ++ pretty e instance Pretty ProgramT where - pretty (ProgramT decls) = concatMap ((++ "\n") . pretty) decls + pretty (ProgramT defs) = concatMap ((++ "\n") . pretty) defs -- cgit v1.2.3-54-g00ecf