@@ -63,9 +63,9 @@ buildFromSource noPrelude interfaces source =
6363 return $ metaModule { types = types }
6464
6565
66−getSortedDependencies :: [FilePath] -> Bool -> FilePath -> IO [String]
67−getSortedDependencies srcDirs noPrelude root =
68− sortDeps =<< readDeps srcDirs noPrelude root
66+getSortedDependencies :: [FilePath] -> Interfaces -> FilePath -> IO [String]
67+getSortedDependencies srcDirs builtIns root =
68+ sortDeps =<< readDeps srcDirs builtIns root
6969
7070type Deps = (FilePath, String, [String])
7171
@@ -80,14 +80,13 @@ sortDeps depends =
8080 mistakes = filter (\scc -> length scc > 1) sccs
8181 msg = "A cyclical module dependency or was detected in: "
8282
83−readDeps :: [FilePath] -> Bool -> FilePath -> IO [Deps]
84−readDeps srcDirs noPrelude root = evalStateT (go root) Set.empty
83+readDeps :: [FilePath] -> Interfaces -> FilePath -> IO [Deps]
84+readDeps srcDirs builtIns root = do
85+ let ifaces = (Set.fromList . Map.keys) builtIns
86+ evalStateT (go ifaces root) Set.empty
8587 where
86− builtIns = if noPrelude then Set.empty
87− else Set.fromList (Map.keys Prelude.interfaces)
88−
89− go :: FilePath -> StateT (Set.Set String) IO [Deps]
90− go root = do
88+ go :: Set.Set String -> FilePath -> StateT (Set.Set String) IO [Deps]
89+ go builtIns root = do
9190 (root', txt) <- liftIO $ getFile srcDirs root
9291 case Parse.dependencies txt of
9392 Left err -> liftIO (putStrLn msg >> print err >> exitFailure)
@@ -98,7 +97,7 @@ readDeps srcDirs noPrelude root = evalStateT (go root) Set.empty
9897 let realDeps = Set.difference (Set.fromList deps) builtIns
9998 newDeps = Set.difference (Set.filter (not . isNative) realDeps) seen
10099 put (Set.insert name (Set.union newDeps seen))
101− rest <- mapM (go . toFilePath) (Set.toList newDeps)
100+ rest <- mapM (go builtIns . toFilePath) (Set.toList newDeps)
102101 return ((makeRelative "." root', name, Set.toList realDeps) : concat rest)
103102
104103getFile :: [FilePath] -> FilePath -> IO (FilePath,String)