@@ -28,37 +28,23 @@ import Data.IntMap (IntMap)
28-- UseMap maps names to the set of used (reachable) argument positions.
28-- UseMap maps names to the set of used (reachable) argument positions.
29type UseMap = Map Name IntSet
29type UseMap = Map Name IntSet
31−-- A dependency, potential edge in the dep graph.
31+type Deps = IntMap (Set (Name, Int))
32−-- Every dependency belongs to a certain Idris function.
33−-- For the effect to take place, the condition must be true.
36− { depArg :: Int -- | This argument of the function should be marked as used.
37− , depCtors :: Set (Name, Int) -- | These ctor fields should be marked as used.
38− , depTags :: Set Name -- | Tags of these ADTs should be marked as used.
41− , depGuards :: Set (Name, Int) -- | All these arguments must be marked as used.
43− deriving (Eq, Ord, Show)
45−-- DepMap maps function names to their sets of dependencies.
46−type DepMap = Map Name (Set Dep)
32+type DepMap = Map Name Deps
48−findUsed :: Context -> Ctxt CGInfo -> [Name] -> UseMap
34+findUsed :: Context -> Ctxt CGInfo -> [Name] -> DepMap
49findUsed ctx cg ns = M.fromList [(n, getDeps n) | n <- ns]
35findUsed ctx cg ns = M.fromList [(n, getDeps n) | n <- ns]
51− getDeps :: Name -> Set Dep
37+ getDeps :: Name -> Deps
52 getDeps n = case lookupDef n ctx of
38 getDeps n = case lookupDef n ctx of
53 [def] -> getDepsDef def
39 [def] -> getDepsDef def
54 [] -> error $ "erasure checker: unknown name: " ++ show n
40 [] -> error $ "erasure checker: unknown name: " ++ show n
55 _ -> error $ "erasure checker: ambiguous name: " ++ show n
41 _ -> error $ "erasure checker: ambiguous name: " ++ show n
57− getDepsDef :: Def -> Set Dep
43+ getDepsDef :: Def -> Deps
58− getDepsDef (Function ty t) = S.empty
44+ getDepsDef (Function ty t) = IM.empty
59− getDepsDef (TyDecl ty t) = S.empty
45+ getDepsDef (TyDecl ty t) = IM.empty
60− getDepsDef (Operator ty n f) = S.empty
46+ getDepsDef (Operator ty n f) = IM.empty
61− getDepsDef (CaseOp ci ty tys def tot cdefs) = S.empty
47+ getDepsDef (CaseOp ci ty tys def tot cdefs) = IM.empty
64buildDepGraph :: Context -> Ctxt CGInfo -> [Name] -> DepGraph
50buildDepGraph :: Context -> Ctxt CGInfo -> [Name] -> DepGraph