setFilterLookup :: (Ord a, Ord b, Ord d, Show a) =>
                   (d -> a) -- ^ projection function
                -> (a -> b -> Bool) -- ^ filter predicate
                -> DepGraph a b c -- ^ dependency graph for lookup
                -> Set.Set d -- ^ filter this set
                -> Set.Set (d, b)
setFilterLookup pf fp gr s = Set.map h $ Set.filter g $ Set.map f s where
    f x = (x, fmap ( \ (v, _, _) -> v ) $ Map.lookup (pf x) $ dataMap gr)
    g (x, Just val) = fp (pf x) val
    g _ = False
    h (x, Just val) = (x, val)
    h _ = error "setFilterLookup: Impossible case"
setFilterLookup :: (Ord a, Ord b, Ord d, Show a) =>
                   (d -> a) -- ^ projection function
                -> (a -> b -> Bool) -- ^ filter predicate
                -> DepGraph a b c -- ^ dependency graph for lookup
                -> Set.Set d -- ^ filter this set
                -> Set.Set (d, b)
setFilterLookup pf fp gr s = Set.map h $ Set.filter g $ Set.map f s where
    f x = (x, fmap ( \ (v, _, _) -> v ) $ Map.lookup (pf x) $ dataMap gr)
    g (x, Just val) = fp (pf x) val
    g _ = False
    h (x, Just val) = (x, val)
    h _ = error "setFilterLookup: Impossible case"
setFilterLookup pf fp gr s = Set.map h $ Set.filter g $ Set.map f s where
    f x = (x, fmap ( \ (v, _, _) -> v ) $ Map.lookup (pf x) $ dataMap gr)
    g (x, Just val) = fp (pf x) val
    g _ = False
    h (x, Just val) = (x, val)
    h _ = error "setFilterLookup: Impossible case"