on master help sign in
Add some comments.
commit3e48badfbc6e4bd3c721d6400c6263d1fbde0bde authorMatus Tejiscak <ziman@functor.sk> dateFri 24 Jan 2014, 12:05 (13 years ago) parentb40a7b2
1 file changed+8−2
src/Idris/Erasure.hs+8−2
src/Idris/Erasure.hs+8−2
@@ -58,9 +58,12 @@ type Vars = Map Name Var
5858type PatVar = Ctors -> Var
5959type PatVars = Map Name PatVar
6060
61−findUsed :: Context -> Ctxt CGInfo -> [Name] -> DepMap
62−findUsed ctx cg ns = dfs M.empty ns
61+buildDepMap :: Context -> Ctxt CGInfo -> [Name] -> DepMap
62+buildDepMap ctx cg ns = dfs M.empty ns
6363 where
64+ -- perform depth-first search
65+ -- to discover all the names used in the program
66+ -- and call getDeps for every name
6467 dfs :: DepMap -> [Name] -> DepMap
6568 dfs dmap [] = dmap
6669 dfs dmap (n : ns)
@@ -71,12 +74,15 @@ findUsed ctx cg ns = dfs M.empty ns
7174 depn = S.delete n (depNames deps)
7275 deps = getDeps n
7376
77+ -- extract all names that a function depends on
78+ -- from the Deps of the function
7479 depNames :: Deps -> Set Name
7580 depNames = S.unions . map (S.unions . map f . S.toList) . IM.elems
7681 where
7782 f :: (Ctors, Cond) -> Set Name
7883 f (ctors, cond) = S.map fst cond -- let's ignore ctors for now
7984
85+ -- get Deps for a Name
8086 getDeps :: Name -> Deps
8187 getDeps n = case lookupDef n ctx of
8288 [def] -> getDepsDef def