@@ -23,7 +23,7 @@ import Control.Lens.Empty
23import Control.Lens.SemiIso
23import Control.Lens.SemiIso
24import Data.Tuple.Morph
24import Data.Tuple.Morph
26−infixl 3 /|/
26+infixl 3 /|/, /?/
27infixl 4 /$/, ~$/, /$~, ~$~
27infixl 4 /$/, ~$/, /$~, ~$~
28infixl 5 /*/, /*, */
28infixl 5 /*/, /*, */
29infixl 1 //=
29infixl 1 //=
@@ -66,17 +66,13 @@ class SemiIsoFunctor f where
66(/$~) :: (SemiIsoFunctor f, HFoldable b', HFoldable b,
66(/$~) :: (SemiIsoFunctor f, HFoldable b', HFoldable b,
67 HUnfoldable b', HUnfoldable b, Rep b' ~ Rep b)
67 HUnfoldable b', HUnfoldable b, Rep b' ~ Rep b)
68 => ASemiIso' a b' -> f b -> f a
68 => 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
73-- | > ai ~$/ f = morphed . ai /$/ f
71-- | > ai ~$/ f = morphed . ai /$/ f
74(~$/) :: (SemiIsoFunctor f, HFoldable a', HFoldable a,
72(~$/) :: (SemiIsoFunctor f, HFoldable a', HFoldable a,
75 HUnfoldable a', HUnfoldable a, Rep a' ~ Rep a)
73 HUnfoldable a', HUnfoldable a, Rep a' ~ Rep a)
76 => ASemiIso' a' b -> f b -> f a
74 => ASemiIso' a' b -> f b -> f a
77−-- TODO GHC 7.10: haddock doesn't work with pattern synynonyms yet
75+ai ~$/ h = morphed . cloneSemiIso ai /$/ h
78−--(SemiIso f g) ~$/ h = morphed . semiIso f g /$/ h
79−ai ~$/ h = withSemiIso ai $ \f g -> morphed . semiIso f g /$/ h
81-- | > ai ~$~ f = morphed . ai . morphed /$/ f
77-- | > ai ~$~ f = morphed . ai . morphed /$/ f
82(~$~) :: (SemiIsoFunctor f,
78(~$~) :: (SemiIsoFunctor f,
@@ -85,9 +81,7 @@ ai ~$/ h = withSemiIso ai $ \f g -> morphed . semiIso f g /$/ h
85 HFoldable b', HUnfoldable b',
81 HFoldable b', HUnfoldable b',
86 Rep b' ~ Rep b, Rep b' ~ Rep a)
82 Rep b' ~ Rep b, Rep b' ~ Rep a)
87 => ASemiIso b' b' b' b' -> f b -> f a
83 => 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
92-- | Equivalent of 'Applicative' for 'SemiIsoFunctor'.
86-- | Equivalent of 'Applicative' for 'SemiIsoFunctor'.
@@ -137,6 +131,10 @@ class SemiIsoApply f => SemiIsoAlternative f where
138 {-# MINIMAL siempty, (/|/) #-}
132 {-# MINIMAL siempty, (/|/) #-}
134+-- | Provides an error message in the case of failure.
135+(/?/) :: SemiIsoAlternative f => f a -> String -> f a
136+f /?/ msg = f /|/ sifail msg
140-- | An analogue of 'Monad' for 'SemiIsoFunctor'.
138-- | An analogue of 'Monad' for 'SemiIsoFunctor'.
142-- Because of the 'no throwing away' rule bind has to \"return\"
140-- Because of the 'no throwing away' rule bind has to \"return\"