git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
simplify ImportDeclaration type checker
commitf9c9dd2b441f8b4334a2240cf9946e0fecf9fcb1 authorBogdan Popa <popa.bogdanp@gmail.com> dateSun 17 Nov 2013, 04:25 (13 years ago) parent0263960
1 file changed+8−13
src/Language/PureScript/TypeChecker.hs+8−13
src/Language/PureScript/TypeChecker.hs+8−13
@@ -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') })