aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Typecheck.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Typecheck.hs b/src/Typecheck.hs
index f6621a0..c86187d 100644
--- a/src/Typecheck.hs
+++ b/src/Typecheck.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE TupleSections #-}
module Typecheck
(inferExpr,
checkExpr)
@@ -15,10 +16,13 @@ assertVar _ = Nothing
assertPtr (TPtr t) = Just t
assertPtr _ = Nothing
+
inferExpr :: Expr -> Environment -> Maybe Typ
inferExpr (Var name) env = lookup name env
inferExpr (IntLit _) _ = Just TInt
-inferExpr (Record _) _ = undefined
+inferExpr (Record ts) env = do
+ tts <- sequence $ map (\(v,e) -> (v,) <$> inferExpr e env) ts
+ return $ TRecord tts
inferExpr (Variant t v e) env = do
ts <- assertVar t
tt <- lookup v ts