blob: a3bc57af7632fd5a8e935822be4492c4c66929b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-- | Module exporting a function that works as a filter on a dependency graph.
-- Given a list of obsolete nodes, this filter will reduce the graph so it only
-- contains obsolete nodes and nodes that depend (directly or indirectly) on
-- obsolete nodes.
--
module Hakyll.Core.DirectedGraph.ObsoleteFilter
( obsoleteFilter
) where
import qualified Data.Set as S
import Hakyll.Core.DirectedGraph
import qualified Hakyll.Core.DirectedGraph as DG
-- | Given a list of obsolete items, filter the dependency graph so it only
-- contains these items
--
obsoleteFilter :: Ord a
=> [a] -- ^ List of obsolete items
-> DirectedGraph a -- ^ Dependency graph
-> DirectedGraph a -- ^ Resulting dependency graph
obsoleteFilter obsolete graph =
let reversed = DG.reverse graph
allObsolete = S.unions $ map (flip reachableNodes reversed) obsolete
in DG.filter (`S.member` allObsolete) graph
|