Comments and MINIMAL pragmas.

This commit is contained in:
Paweł Nowak 2014-11-23 01:17:43 +01:00
parent c8f2ec4c6a
commit 1799ff11b4

View File

@ -125,6 +125,10 @@ class SemiIsoApply f => SemiIsoAlternative f where
{-# MINIMAL siempty, (/|/) #-}
-- | An analogue of 'Monad' for 'SemiIsoFunctor'.
--
-- Because of the 'no throwing away' rule bind has to \"return\"
-- both @a@ and @b@.
class SemiIsoApply m => SemiIsoMonad m where
(//=) :: m a -> (a -> m b) -> m (a, b)
m //= f = swapped /$/ (f =// m)
@ -132,14 +136,20 @@ class SemiIsoApply m => SemiIsoMonad m where
(=//) :: (b -> m a) -> m b -> m (a, b)
f =// m = swapped /$/ (m //= f)
{-# MINIMAL (//=) | (=//) #-}
-- | A SemiIsoMonad with fixed point operator.
class SemiIsoMonad m => SemiIsoFix m where
sifix :: (a -> m a) -> m a
sifix f = dup /$/ (f =//= f)
where dup = semiIso (\a -> Right (a, a)) (Right . fst)
-- | Fixed point combined with bind, it's so symmetric!
(=//=) :: (a -> m b) -> (b -> m a) -> m (a, b)
f =//= g = sifix (\(a, b) -> g b /*/ f a)
{-# MINIMAL sifix | (=//=) #-}
-- | Equivalent of 'sequence'.
--
-- Note that it is not possible to write sequence_, because