Change "find" to "targets", for clarity.
This commit is contained in:
parent
d9df114909
commit
f515b5ce55
|
@ -88,10 +88,10 @@ contains = IntMap.fromList [(typeKey t,
|
||||||
-- | Does one type contain another?
|
-- | Does one type contain another?
|
||||||
-- (A type always contains itself.)
|
-- (A type always contains itself.)
|
||||||
typeContains :: TypeKey -> TypeKey -> Bool
|
typeContains :: TypeKey -> TypeKey -> Bool
|
||||||
typeContains start find
|
typeContains start target
|
||||||
| start == find = True
|
| start == target = True
|
||||||
| otherwise = case IntMap.lookup start contains of
|
| otherwise = case IntMap.lookup start contains of
|
||||||
Just set -> find `IntSet.member` set
|
Just set -> target `IntSet.member` set
|
||||||
Nothing -> True -- can't tell, so it might be
|
Nothing -> True -- can't tell, so it might be
|
||||||
|
|
||||||
-- | Type-smart generic mapM.
|
-- | Type-smart generic mapM.
|
||||||
|
@ -101,12 +101,12 @@ gmapMFor :: (Monad m, Data t) =>
|
||||||
[TypeKey] -- ^ Target types
|
[TypeKey] -- ^ Target types
|
||||||
-> (forall s. Data s => s -> m s) -- ^ Function to apply
|
-> (forall s. Data s => s -> m s) -- ^ Function to apply
|
||||||
-> (t -> m t) -- ^ Generic operation
|
-> (t -> m t) -- ^ Generic operation
|
||||||
gmapMFor find f = gmapM (each f)
|
gmapMFor targets f = gmapM (each f)
|
||||||
where
|
where
|
||||||
each :: (Monad m, Data t) =>
|
each :: (Monad m, Data t) =>
|
||||||
(forall s. Data s => s -> m s) -> (t -> m t)
|
(forall s. Data s => s -> m s) -> (t -> m t)
|
||||||
each f x
|
each f x
|
||||||
= if cont then f x else return x
|
= if cont then f x else return x
|
||||||
where
|
where
|
||||||
cont = or $ map (typeContains xKey) find
|
cont = or $ map (typeContains xKey) targets
|
||||||
xKey = typeKey x
|
xKey = typeKey x
|
||||||
|
|
Loading…
Reference in New Issue
Block a user