aboutsummaryrefslogtreecommitdiff
path: root/ast/CC/Typed.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ast/CC/Typed.hs')
-rw-r--r--ast/CC/Typed.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/ast/CC/Typed.hs b/ast/CC/Typed.hs
index 535fd31..53caa29 100644
--- a/ast/CC/Typed.hs
+++ b/ast/CC/Typed.hs
@@ -3,6 +3,8 @@ module CC.Typed(
module CC.Types
) where
+import Data.List
+
import CC.Pretty
import CC.Types
@@ -15,12 +17,14 @@ data DefT = DefT Name ExprT
data TypeT = TFunT TypeT TypeT
| TIntT
+ | TTupT [TypeT]
| TyVar Int
deriving (Show, Read)
data ExprT = LamT TypeT Occ ExprT
| CallT TypeT ExprT ExprT
| IntT Int
+ | TupT [ExprT]
| VarT Occ
deriving (Show, Read)
@@ -31,12 +35,15 @@ exprType :: ExprT -> TypeT
exprType (LamT typ _ _) = typ
exprType (CallT typ _ _) = typ
exprType (IntT _) = TIntT
+exprType (TupT es) = TTupT (map exprType es)
exprType (VarT (Occ _ typ)) = typ
instance Pretty TypeT where
prettyPrec _ TIntT = "Int"
prettyPrec p (TFunT a b) =
precParens p 2 (prettyPrec 3 a ++ " -> " ++ prettyPrec 2 b)
+ prettyPrec _ (TTupT ts) =
+ "(" ++ intercalate ", " (map pretty ts) ++ ")"
prettyPrec _ (TyVar i) = 't' : show i
instance Pretty ExprT where
@@ -48,6 +55,7 @@ instance Pretty ExprT where
precParens p 2 $
prettyPrec 3 e1 ++ " " ++ prettyPrec 3 e2 ++ " :: " ++ pretty ty
prettyPrec _ (IntT i) = show i
+ prettyPrec _ (TupT es) = "(" ++ intercalate ", " (map pretty es) ++ ")"
prettyPrec p (VarT (Occ n t)) =
precParens p 2 $
show n ++ " :: " ++ pretty t