@@ -63,9 +63,9 @@ buildFromSource noPrelude interfaces source =
63 return $ metaModule { types = types }
63 return $ metaModule { types = types }
66−getSortedDependencies :: [FilePath] -> Bool -> FilePath -> IO [String]
66+getSortedDependencies :: [FilePath] -> Interfaces -> FilePath -> IO [String]
67−getSortedDependencies srcDirs noPrelude root =
67+getSortedDependencies srcDirs builtIns root =
68− sortDeps =<< readDeps srcDirs noPrelude root
68+ sortDeps =<< readDeps srcDirs builtIns root
70type Deps = (FilePath, String, [String])
70type Deps = (FilePath, String, [String])
@@ -80,14 +80,13 @@ sortDeps depends =
80 mistakes = filter (\scc -> length scc > 1) sccs
80 mistakes = filter (\scc -> length scc > 1) sccs
81 msg = "A cyclical module dependency or was detected in: "
81 msg = "A cyclical module dependency or was detected in: "
83−readDeps :: [FilePath] -> Bool -> FilePath -> IO [Deps]
83+readDeps :: [FilePath] -> Interfaces -> FilePath -> IO [Deps]
84+readDeps srcDirs builtIns root = do
85+ let ifaces = (Set.fromList . Map.keys) builtIns
84−readDeps srcDirs noPrelude root = evalStateT (go root) Set.empty
86+ evalStateT (go ifaces root) Set.empty
86− builtIns = if noPrelude then Set.empty
87− else Set.fromList (Map.keys Prelude.interfaces)
89− go :: FilePath -> StateT (Set.Set String) IO [Deps]
88+ go :: Set.Set String -> FilePath -> StateT (Set.Set String) IO [Deps]
90− go root = do
89+ go builtIns root = do
91 (root', txt) <- liftIO $ getFile srcDirs root
90 (root', txt) <- liftIO $ getFile srcDirs root
92 case Parse.dependencies txt of
91 case Parse.dependencies txt of
93 Left err -> liftIO (putStrLn msg >> print err >> exitFailure)
92 Left err -> liftIO (putStrLn msg >> print err >> exitFailure)
@@ -98,7 +97,7 @@ readDeps srcDirs noPrelude root = evalStateT (go root) Set.empty
98 let realDeps = Set.difference (Set.fromList deps) builtIns
97 let realDeps = Set.difference (Set.fromList deps) builtIns
99 newDeps = Set.difference (Set.filter (not . isNative) realDeps) seen
98 newDeps = Set.difference (Set.filter (not . isNative) realDeps) seen
100 put (Set.insert name (Set.union newDeps seen))
99 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)
102 return ((makeRelative "." root', name, Set.toList realDeps) : concat rest)
101 return ((makeRelative "." root', name, Set.toList realDeps) : concat rest)
104getFile :: [FilePath] -> FilePath -> IO (FilePath,String)
103getFile :: [FilePath] -> FilePath -> IO (FilePath,String)