@@ -66,7 +66,6 @@ module Control.Lens.SemiIso (
6666
6767 -- * Semi-isos for numbers.
6868 _Negative,
69− _Positive,
7069
7170 -- * Transforming semi-isos.
7271 rev,
@@ -194,11 +193,16 @@ bifiltered p = semiIso check check
194193 where check x | p x = Right x
195194 | otherwise = Left "bifiltered: predicate failed"
196195
197−_Negative :: Num a => SemiIso' a a
198−_Negative = undefined
199−
200−_Positive :: Num a => SemiIso' a a
201−_Positive = undefined
196+-- | \-> Matches only negative numbers, turns it into a positive one.
197+--
198+-- \<- Matches only positive numbers, turns it into a negative one.
199+_Negative :: Real a => SemiIso' a a
200+_Negative = semiIso f g
201+ where
202+ f x | x < 0 = Right (-x)
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"
202206
203207-- | Reverses a 'SemiIso'.
204208rev :: ASemiIso s t a b -> SemiIso b a t s