git.iko.soy/semi-iso-optics
on master help sign in
Add sifail, bump version to 0.4.1.0
commiteb505093aebc83b2ace567fff73b86afbcc7b745 authorPaweł Nowak <pawel834@gmail.com> dateSun 23 Nov 2014, 17:16 (12 years ago) parent82588b5
3 files changed+10−1
Control/Lens/SemiIso.hs+5 Data/SemiIsoFunctor.hs+4 semi-iso.cabal+1−1
Control/Lens/SemiIso.hs+5
@@ -63,6 +63,7 @@ module Control.Lens.SemiIso (
6363 constant,
6464 exact,
6565 bifiltered,
66+ alwaysFailing,
6667
6768 -- * Semi-isos for numbers.
6869 _Negative,
@@ -193,6 +194,10 @@ bifiltered p = semiIso check check
193194 where check x | p x = Right x
194195 | otherwise = Left "bifiltered: predicate failed"
195196
197+-- | A semi-iso that fails in both directions.
198+alwaysFailing :: String -> SemiIso s t a b
199+alwaysFailing msg = semiIso (\_ -> Left msg) (\_ -> Left msg)
200+
196201-- | \-> Matches only negative numbers, turns it into a positive one.
197202--
198203-- \<- Matches only positive numbers, turns it into a negative one.
Data/SemiIsoFunctor.hs+4
@@ -117,6 +117,10 @@ class SemiIsoFunctor f => SemiIsoApply f where
117117
118118 {-# MINIMAL (siunit | sipure), (/*/) #-}
119119
120+-- | Fails with a message.
121+sifail :: SemiIsoApply f => String -> f a
122+sifail msg = alwaysFailing msg /$/ siunit
123+
120124-- | Equivalent of 'Alternative' for 'SemiIsoFunctor'.
121125--
122126-- @f a@ should form a monoid with identity 'siempty' and binary
semi-iso.cabal+1−1
@@ -1,5 +1,5 @@
11name: semi-iso
2−version: 0.4.0.0
2+version: 0.4.1.0
33synopsis: Weakened partial isomorphisms that work with lenses.
44description: Semi-isomorphisms are partial isomorphisms with weakened iso laws.
55 And they work with Iso and Prism from @lens@!