git.iko.soy/semi-iso-optics
on master help sign in
Bump version to 0.4.2.0. Add 'cloneSemiIso' and '/?/'.
commit84b6967d703fbb5ae837ce275115cf3b5720f847 authorPaweł Nowak <pawel834@gmail.com> dateTue 25 Nov 2014, 19:08 (12 years ago) parenteb50509
3 files changed+14−11
Control/Lens/SemiIso.hs+5 Data/SemiIsoFunctor.hs+8−10 semi-iso.cabal+1−1
Control/Lens/SemiIso.hs+5
@@ -48,6 +48,7 @@ module Control.Lens.SemiIso (
4848
4949 -- * Constructing semi-isos.
5050 semiIso,
51+ cloneSemiIso,
5152
5253 -- * Consuming semi-isos.
5354 apply,
@@ -131,6 +132,10 @@ pattern SemiIso sa bt <- (viewSemiIso -> (sa, bt))
131132semiIso :: (s -> Either String a) -> (b -> Either String t) -> SemiIso s t a b
132133semiIso sa bt = merge . dimap sa (sequenceA . fmap bt) . expose
133134
135+-- | Clones a semi-iso.
136+cloneSemiIso :: ASemiIso s t a b -> SemiIso s t a b
137+cloneSemiIso (SemiIso sa bt) = semiIso sa bt
138+
134139-- | Applies the 'SemiIso'.
135140apply :: ASemiIso s t a b -> s -> Either String a
136141apply (SemiIso sa _) = sa
Data/SemiIsoFunctor.hs+8−10
@@ -23,7 +23,7 @@ import Control.Lens.Empty
2323import Control.Lens.SemiIso
2424import Data.Tuple.Morph
2525
26−infixl 3 /|/
26+infixl 3 /|/, /?/
2727infixl 4 /$/, ~$/, /$~, ~$~
2828infixl 5 /*/, /*, */
2929infixl 1 //=
@@ -66,17 +66,13 @@ class SemiIsoFunctor f where
6666(/$~) :: (SemiIsoFunctor f, HFoldable b', HFoldable b,
6767 HUnfoldable b', HUnfoldable b, Rep b' ~ Rep b)
6868 => ASemiIso' a b' -> f b -> f a
69−-- TODO GHC 7.10: haddock doesn't work with pattern synynonyms yet
70−-- (SemiIso f g) /$~ h = semiIso f g . morphed /$/ h
71−ai /$~ h = withSemiIso ai $ \f g -> semiIso f g . morphed /$/ h
69+ai /$~ h = cloneSemiIso ai . morphed /$/ h
7270
7371-- | > ai ~$/ f = morphed . ai /$/ f
7472(~$/) :: (SemiIsoFunctor f, HFoldable a', HFoldable a,
7573 HUnfoldable a', HUnfoldable a, Rep a' ~ Rep a)
7674 => ASemiIso' a' b -> f b -> f a
77−-- TODO GHC 7.10: haddock doesn't work with pattern synynonyms yet
78−--(SemiIso f g) ~$/ h = morphed . semiIso f g /$/ h
79−ai ~$/ h = withSemiIso ai $ \f g -> morphed . semiIso f g /$/ h
75+ai ~$/ h = morphed . cloneSemiIso ai /$/ h
8076
8177-- | > ai ~$~ f = morphed . ai . morphed /$/ f
8278(~$~) :: (SemiIsoFunctor f,
@@ -85,9 +81,7 @@ ai ~$/ h = withSemiIso ai $ \f g -> morphed . semiIso f g /$/ h
8581 HFoldable b', HUnfoldable b',
8682 Rep b' ~ Rep b, Rep b' ~ Rep a)
8783 => ASemiIso b' b' b' b' -> f b -> f a
88−-- TODO GHC 7.10: haddock doesn't work with pattern synynonyms yet
89−--(SemiIso f g) ~$~ h = morphed . semiIso f g . morphed /$/ h
90−ai ~$~ h = withSemiIso ai $ \f g -> morphed . semiIso f g . morphed /$/ h
84+ai ~$~ h = morphed . cloneSemiIso ai . morphed /$/ h
9185
9286-- | Equivalent of 'Applicative' for 'SemiIsoFunctor'.
9387--
@@ -137,6 +131,10 @@ class SemiIsoApply f => SemiIsoAlternative f where
137131
138132 {-# MINIMAL siempty, (/|/) #-}
139133
134+-- | Provides an error message in the case of failure.
135+(/?/) :: SemiIsoAlternative f => f a -> String -> f a
136+f /?/ msg = f /|/ sifail msg
137+
140138-- | An analogue of 'Monad' for 'SemiIsoFunctor'.
141139--
142140-- Because of the 'no throwing away' rule bind has to \"return\"
semi-iso.cabal+1−1
@@ -1,5 +1,5 @@
11name: semi-iso
2−version: 0.4.1.0
2+version: 0.4.2.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@!