mirror of
https://github.com/ilyakooo0/semi-iso-optics.git
synced 2024-09-11 07:55:36 +03:00
Added 'bifiltered' semi-iso.
This commit is contained in:
parent
180dcbcb79
commit
a7625c3c39
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user