[accessor function for SynthesisContext
martin.hofmann@uni-bamberg.de**20090428121013] hunk ./src/Context/SynthesisContext.hs 139
+lookIn :: (Ord a, Show a, MonadState SynCtx m) => (SynCtx -> Map.Map a b) -> a -> m b
+lookIn f n = gets f >>= \m ->  
+    maybe (fail $ "Not in context: " ++ (show n))
+          return
+          (Map.lookup n m)
hunk ./src/Context/SynthesisContext.hs 145
-getVarType :: (MonadState SynCtx m) => Name -> m Type
-getVarType n = do
-    m <- gets sctx_types
-    case Map.lookup n m of
-        (Just t) -> return t
-        _owise   -> fail $ "Variable not in context: " ++ (show n) 
-
-getConType :: (MonadState SynCtx m) => Name -> m Type
-getConType n = do
-    m <- gets sctx_ctors 
-    case Map.lookup n m of
-        (Just t) -> return t
-        _owise   -> fail $ "Ctor not in context: " ++ (show n)
+getConType, getVarType :: (MonadState SynCtx m) => Name -> m Type
+getVarType = lookIn sctx_types
+getConType = lookIn sctx_ctors
hunk ./src/Context/SynthesisContext.hs 150
-getSubClasses n = do
-    m <- gets sctx_classes
-    case Map.lookup n m of
-        (Just t) -> return t
-        _owise   -> fail $ "Class not in context: " ++ (show n)
+getSubClasses = lookIn sctx_classes
hunk ./src/Context/SynthesisContext.hs 153
-getInstances n = do
-    m <- gets sctx_instances
-    case Map.lookup n m of
-        (Just t) -> return t
+getInstances = lookIn sctx_instances