@@ -1,4 +1,4 @@
1−module Initialize (buildFromSource, getSortedModuleNames, Interfaces) where
1+module Initialize (buildFromSource, getSortedDependencies) where
3import Data.Data
3import Data.Data
4import Control.Monad.State
4import Control.Monad.State
@@ -56,11 +56,11 @@ buildFromSource noPrelude interfaces source =
56 return $ metaModule { types = types, exports = exports' }
56 return $ metaModule { types = types, exports = exports' }
59−getSortedModuleNames :: Bool -> FilePath -> IO [String]
59+getSortedDependencies :: Bool -> FilePath -> IO [String]
60−getSortedModuleNames noPrelude root =
60+getSortedDependencies noPrelude root =
61 sortDeps =<< readDeps noPrelude root
61 sortDeps =<< readDeps noPrelude root
63−type Deps = (String, [String])
63+type Deps = (FilePath, String, [String])
65sortDeps :: [Deps] -> IO [String]
65sortDeps :: [Deps] -> IO [String]
66sortDeps depends =
66sortDeps depends =
@@ -68,8 +68,7 @@ sortDeps depends =
68 then return (concat sccs)
68 then return (concat sccs)
69 else print msg >> mapM print mistakes >> exitFailure
69 else print msg >> mapM print mistakes >> exitFailure
71− graph = map (\(name, deps) -> (toFilePath name, name, deps)) depends
72− sccs = map Graph.flattenSCC $ Graph.stronglyConnComp graph
71+ sccs = map Graph.flattenSCC $ Graph.stronglyConnComp depends
74 mistakes = filter (\scc -> length scc > 1) sccs
73 mistakes = filter (\scc -> length scc > 1) sccs
75 msg = "A cyclical module dependency or was detected in: "
74 msg = "A cyclical module dependency or was detected in: "
@@ -93,7 +92,7 @@ readDeps noPrelude root = evalStateT (go root) Set.empty
93 newDeps = Set.difference (Set.filter (not . isNative) realDeps) seen
92 newDeps = Set.difference (Set.filter (not . isNative) realDeps) seen
94 put (Set.insert name (Set.union newDeps seen))
93 put (Set.insert name (Set.union newDeps seen))
95 rest <- mapM (go . toFilePath) (Set.toList newDeps)
94 rest <- mapM (go . toFilePath) (Set.toList newDeps)
96− return ((name, Set.toList realDeps) : concat rest)
95+ return ((makeRelative "." root, name, Set.toList realDeps) : concat rest)
99isNative name = List.isPrefixOf "Native." name
98isNative name = List.isPrefixOf "Native." name