Permalink
Browse files

+ Typing environment

  • Loading branch information...
1 parent 6e6e7bf commit c596e372bb9a638d624151a8379b0591b54e3be5 @Averethel committed Feb 9, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 TypeInference/Env.hs
View
@@ -0,0 +1,23 @@
+{-# LANGUAGE
+ FlexibleContexts
+ #-}
+
+module TypeInference.Env (Env, emptyEnv, get, extend) where
+ import Types
+ import Utils.Errors
+
+ import Control.Monad.Error
+
+ type Env = [(String, Type)]
+
+ emptyEnv :: Env
+ emptyEnv = []
+
+ get :: MonadError String m => String -> Env -> m Type
+ get v env =
+ case v `lookup` env of
+ Nothing -> throwError $ unboundVariable v
+ Just tp -> return tp
+
+ extend :: Env -> (String, Type) -> Env
+ extend = flip (:)

0 comments on commit c596e37

Please sign in to comment.