@@ -325,11 +325,8 @@ infer' app@(App _ _) = do
325325 checkFunctionApplications ft argss ret
326326 return ret
327327infer' (Var var@(Qualified mp name)) = do
328− env <- getEnv
329− modulePath <- checkModulePath `fmap` get
330− case M.lookup (qualify modulePath var) (names env) of
331− Nothing -> throwError $ show var ++ " is undefined"
332− Just (ty, _) -> replaceAllTypeSynonyms ty
328+ ty <- lookupVariable var
329+ replaceAllTypeSynonyms ty
333330infer' (Block ss) = do
334331 ret <- fresh
335332 (allCodePathsReturn, _) <- checkBlock M.empty ret ss
@@ -613,13 +610,9 @@ check' app@(App _ _) ret = do
613610 ft <- infer f
614611 checkFunctionApplications ft argss ret
615612check' v@(Var var@(Qualified mp name)) ty = do
616− env <- getEnv
617− modulePath <- checkModulePath <$> get
618− case M.lookup (qualify modulePath var) (names env) of
619− Nothing -> throwError $ show var ++ " is undefined"
620− Just (ty1, _) -> do
621− repl <- replaceAllTypeSynonyms ty1
622− repl `subsumes` ty
613+ ty1 <- lookupVariable var
614+ repl <- replaceAllTypeSynonyms ty1
615+ repl `subsumes` ty
623616check' (TypedValue val ty1) ty2 = do
624617 kind <- liftCheck $ kindOf ty1
625618 guardWith ("Expected type of kind *, was " ++ prettyPrintKind kind) $ kind == Star