@@ -66,7 +66,6 @@ module Control.Lens.SemiIso (
67 -- * Semi-isos for numbers.
67 -- * Semi-isos for numbers.
68 _Negative,
68 _Negative,
71 -- * Transforming semi-isos.
70 -- * Transforming semi-isos.
@@ -194,11 +193,16 @@ bifiltered p = semiIso check check
194 where check x | p x = Right x
193 where check x | p x = Right x
195 | otherwise = Left "bifiltered: predicate failed"
194 | otherwise = Left "bifiltered: predicate failed"
196+-- | \-> Matches only negative numbers, turns it into a positive one.
198+-- \<- Matches only positive numbers, turns it into a negative one.
197−_Negative :: Num a => SemiIso' a a
199+_Negative :: Real a => SemiIso' a a
198−_Negative = undefined
200+_Negative = semiIso f g
200−_Positive :: Num a => SemiIso' a a
202+ f x | x < 0 = Right (-x)
201−_Positive = undefined
203+ | otherwise = Left "_Negative: apply expected a negative number"
204+ g x | x >= 0 = Right (-x)
205+ | otherwise = Left "_Negative: unapply expected a positive number"
203-- | Reverses a 'SemiIso'.
207-- | Reverses a 'SemiIso'.
204rev :: ASemiIso s t a b -> SemiIso b a t s
208rev :: ASemiIso s t a b -> SemiIso b a t s