@@ -120,18 +120,12 @@ typeCheckAll (ModuleDeclaration name decls : rest) = do
120120typeCheckAll (ImportDeclaration modulePath idents : rest) = do
121121 env <- getEnv
122122 omp <- checkModulePath `fmap` get
123− rethrow errorMessage $
124− guardWith "module does not exist" $ moduleExists env
125− case idents of
126− Nothing -> do
127− let idents = map snd $ filterModule env
128− rethrow errorMessage $
129− bindIdents idents omp env
130− typeCheckAll rest
131− Just idents -> do
132− rethrow errorMessage $
133− bindIdents idents omp env
134− typeCheckAll rest
123+ rethrow errorMessage $ do
124+ guardWith "module does not exist" $ moduleExists env
125+ case idents of
126+ Nothing -> bindIdents (map snd $ filterModule env) omp env
127+ Just idents -> bindIdents idents omp env
128+ typeCheckAll rest
135129 where errorMessage = (("Error importing " ++ show modulePath ++ ": ") ++)
136130 filterModule env = filter (\(m, _) -> m == modulePath) (M.keys (names env))
137131 moduleExists env = not $ null $ filterModule env
@@ -140,4 +134,5 @@ typeCheckAll (ImportDeclaration modulePath idents : rest) = do
140134 case M.lookup (modulePath, ident) (names env) of
141135 Nothing -> throwError $ show modulePath ++ "." ++ show ident ++ " is undefined"
142136 Just (pt, _) -> getEnv >>= \env' ->
143− putEnv (env' { names = M.insert (omp, ident) (pt, Alias modulePath ident) (names env') })
137+ putEnv (env' { names = M.insert (omp, ident) (pt, Alias modulePath ident)
138+ (names env') })