@@ -77,13 +77,17 @@ forwardChain deps
77-- Build the dependency graph,
77-- Build the dependency graph,
78-- starting the depth-first search from a list of Names.
78-- starting the depth-first search from a list of Names.
79buildDepMap :: Context -> [Name] -> Deps
79buildDepMap :: Context -> [Name] -> Deps
80−buildDepMap ctx ns = addMain $ dfs S.empty M.empty ns
80+buildDepMap ctx ns = addPostulates $ dfs S.empty M.empty ns
82 -- mark the result of Main.main as used with the empty assumption
82 -- mark the result of Main.main as used with the empty assumption
83− addMain :: Deps -> Deps
83+ addPostulates :: Deps -> Deps
84− addMain = M.insertWith S.union S.empty $ S.singleton (main, Result)
84+ addPostulates deps = foldr (\(ds, rs) -> M.insertWith S.union ds rs) deps postulates
86− main = NS (UN $ pack "main") [pack "Main"]
86+ (==>) ds rs = (S.fromList ds, S.fromList rs)
87+ (.:) ms n = NS (UN $ pack n) (map pack ms)
89+ [ [] ==> [(["Main"] .: "main", Result)]
88 -- perform depth-first search
92 -- perform depth-first search
89 -- to discover all the names used in the program
93 -- to discover all the names used in the program