Added 'bifiltered' semi-iso.

This commit is contained in:
Paweł Nowak 2014-11-23 14:17:14 +01:00
parent 180dcbcb79
commit a7625c3c39

View File

@ -62,6 +62,7 @@ module Control.Lens.SemiIso (
morphed,
constant,
exact,
bifiltered,
-- * Semi-isos for numbers.
_Negative,
@ -187,6 +188,12 @@ exact x = semiIso f g
g y | x == y = Right ()
| otherwise = Left "exact: not equal"
-- | Like 'filtered' but checks the predicate in both ways.
bifiltered :: (a -> Bool) -> SemiIso' a a
bifiltered p = semiIso check check
where check x | p x = Right x
| otherwise = Left "bifiltered: predicate failed"
_Negative :: Num a => SemiIso' a a
_Negative = undefined