Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Typing environment

  • Loading branch information...
commit c596e372bb9a638d624151a8379b0591b54e3be5 1 parent 6e6e7bf
@Averethel authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 TypeInference/Env.hs
View
23 TypeInference/Env.hs
@@ -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 (:)
Please sign in to comment.
Something went wrong with that request. Please try again.