git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Revert "Don't require that all types are exported"
4fc4a02Gary Burgess
src/Language/PureScript/TypeChecker.hs+12
@@ -273,6 +273,7 @@ typeCheckModule (Module ss coms mn decls (Just exps)) = warnAndRethrow (addHint
273 modify (\s -> s { checkCurrentModule = Just mn })
273 modify (\s -> s { checkCurrentModule = Just mn })
274 decls' <- typeCheckAll mn exps decls
274 decls' <- typeCheckAll mn exps decls
275 forM_ exps $ \e -> do
275 forM_ exps $ \e -> do
276+ checkTypesAreExported e
276 checkClassMembersAreExported e
277 checkClassMembersAreExported e
277 checkClassesAreExported e
278 checkClassesAreExported e
278 return $ Module ss coms mn decls' (Just exps)
279 return $ Module ss coms mn decls' (Just exps)
@@ -294,6 +295,17 @@ typeCheckModule (Module ss coms mn decls (Just exps)) = warnAndRethrow (addHint
294 exports _ _ = False
295 exports _ _ = False
295 checkMemberExport _ _ = return ()
296 checkMemberExport _ _ = return ()
296
297
298+ -- Check that all the type constructors defined in the current module that appear in member types
299+ -- have also been exported from the module
300+ checkTypesAreExported :: DeclarationRef -> Check ()
301+ checkTypesAreExported = checkMemberExport findTcons
302+ where
303+ findTcons :: Type -> [DeclarationRef]
304+ findTcons = everythingOnTypes (++) go
305+ where
306+ go (TypeConstructor (Qualified (Just mn') name)) | mn' == mn = [TypeRef name (error "Data constructors unused in checkTypesAreExported")]
307+ go _ = []
308+
297 -- Check that all the classes defined in the current module that appear in member types have also
309 -- Check that all the classes defined in the current module that appear in member types have also
298 -- been exported from the module
310 -- been exported from the module
299 checkClassesAreExported :: DeclarationRef -> Check ()
311 checkClassesAreExported :: DeclarationRef -> Check ()