aboutsummaryrefslogtreecommitdiff
path: root/ast/CC/AST/Typed.hs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-24 22:25:50 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-24 22:25:50 +0200
commitf7c3b21c0a10b11730bdce64e7e895bd1eb65fd0 (patch)
tree56a4456840b053d7c8e44d67247de0e4637e2c75 /ast/CC/AST/Typed.hs
parentd951a11b1141b9f4c1ee50c7f89b68c552883c16 (diff)
Lift TypeScheme to AST.Typed
Diffstat (limited to 'ast/CC/AST/Typed.hs')
-rw-r--r--ast/CC/AST/Typed.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/ast/CC/AST/Typed.hs b/ast/CC/AST/Typed.hs
index f4c4d56..537c7a4 100644
--- a/ast/CC/AST/Typed.hs
+++ b/ast/CC/AST/Typed.hs
@@ -21,6 +21,9 @@ data TypeT = TFunT TypeT TypeT
| TyVar Int
deriving (Show, Read)
+data TypeSchemeT = TypeSchemeT [Int] TypeT
+ deriving (Show, Read)
+
data ExprT = LamT TypeT Occ ExprT
| CallT TypeT ExprT ExprT
| IntT Int
@@ -46,6 +49,12 @@ instance Pretty TypeT where
"(" ++ intercalate ", " (map pretty ts) ++ ")"
prettyPrec _ (TyVar i) = 't' : show i
+instance Pretty TypeSchemeT where
+ prettyPrec p (TypeSchemeT bnds ty) =
+ precParens p 2
+ ("forall " ++ intercalate " " (map (pretty . TyVar) bnds) ++ ". " ++
+ prettyPrec 2 ty)
+
instance Pretty ExprT where
prettyPrec p (LamT ty (Occ n t) e) =
precParens p 2 $