Permalink
Browse files

+ Typing of constants

  • Loading branch information...
1 parent c596e37 commit 5391a67275627b4823c40772c0f187bd57527d66 @Averethel committed Feb 9, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 TypeInference/Constant.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE
+ FlexibleContexts
+ #-}
+
+module TypeInference.Constant where
+ import Syntax.Constant
+ import Types
+
+ import TypeInference.Counter
+
+ import Control.Monad.State
+
+ typeOfConstant :: MonadState Counter m => Constant -> m Type
+ typeOfConstant (Cint _) = return Tint
+ typeOfConstant (Cbool _) = return Tbool
+ typeOfConstant Cnil = do
+ v <- freshVar
+ return $ Tlist v
+ typeOfConstant Cunit = return Tunit

0 comments on commit 5391a67

Please sign in to comment.