-- |
-- A symmetric version of the Kleisli monad transformer arrow.
-- This admits three isomorphic 'MonadBijection' types:
--
-- * @'MonadArrow' ('<->') m a b@
-- * @'Bijection' ('MonadFunction' m) a b@
-- * @m a '<->' m b@
--
-- The Alimarine paper just calls it \"MoT\" for Monad Transformer.
{-# LANGUAGE CPP, TupleSections, FlexibleInstances, FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeOperators #-}
#if !(defined(VERSION_semigroupoids) && MIN_VERSION_semigroupoids(5,2,2))
{-# LANGUAGE Safe #-}
#endif
module Control.Invertible.MonadArrow
  ( MonadArrow(..)
  , MonadFunction
  , MonadBijection
  , MonadBijection'
  , MonadBijection''
  , monadBijection
  , monadBijection'
  ) where

import Prelude hiding (id, (.))

import Control.Category
import Control.Arrow
import Control.Monad (MonadPlus(..))
#ifdef VERSION_semigroupoids
import Data.Semigroupoid (Semigroupoid(..))
import Data.Groupoid (Groupoid(..))
#endif

import Data.Invertible.Bijection
import Data.Invertible.TH
import Control.Invertible.BiArrow

-- |Bidirectional 'Control.Arrow.Kleisli'-like monad arrow transformer.
newtype MonadArrow a m b c = MonadArrow { forall (a :: * -> * -> *) (m :: * -> *) b c.
MonadArrow a m b c -> a (m b) (m c)
runMonadArrow :: a (m b) (m c) }

-- |Specialization of 'MonadArrow' to function arrows.
type MonadFunction = MonadArrow (->)

type MonadBijection m = MonadArrow (<->) m
type MonadBijection' m = Bijection (MonadFunction m)
type MonadBijection'' m a b = m a <-> m b

-- |Convert between isomorphic representations of 'MonadBijection's.
monadBijection :: MonadBijection' m a b <-> MonadBijection m a b
monadBijection :: forall (m :: * -> *) a b.
MonadBijection' m a b <-> MonadBijection m a b
monadBijection = [biCase|MonadArrow f :<->: MonadArrow g <-> (MonadArrow (f :<->: g))|]

-- |Convert between isomorphic representations of 'MonadBijection's.
monadBijection' :: MonadBijection'' m a b <-> MonadBijection' m a b
monadBijection' :: forall (m :: * -> *) a b.
MonadBijection'' m a b <-> MonadBijection' m a b
monadBijection' = [biCase|f :<->: g <-> MonadArrow f :<->: MonadArrow g|]

instance Category a => Category (MonadArrow a m) where
  id :: forall a. MonadArrow a m a a
id = a (m a) (m a) -> MonadArrow a m a a
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow a (m a) (m a)
forall a. a a a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
  MonadArrow a (m b) (m c)
f . :: forall b c a.
MonadArrow a m b c -> MonadArrow a m a b -> MonadArrow a m a c
. MonadArrow a (m a) (m b)
g = a (m a) (m c) -> MonadArrow a m a c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (a (m b) (m c)
f a (m b) (m c) -> a (m a) (m b) -> a (m a) (m c)
forall b c a. a b c -> a a b -> a a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a (m a) (m b)
g)

instance Monad m => Arrow (MonadArrow (->) m) where
  arr :: forall b c. (b -> c) -> MonadArrow (->) m b c
arr = (m b -> m c) -> MonadArrow (->) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m b -> m c) -> MonadArrow (->) m b c)
-> ((b -> c) -> m b -> m c) -> (b -> c) -> MonadArrow (->) m b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (m b -> m c) -> m b -> m c
forall b c. (b -> c) -> b -> c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((m b -> m c) -> m b -> m c)
-> ((b -> c) -> m b -> m c) -> (b -> c) -> m b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (b -> c) -> m b -> m c
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
  first :: forall b c d.
MonadArrow (->) m b c -> MonadArrow (->) m (b, d) (c, d)
first  (MonadArrow m b -> m c
f) = (m (b, d) -> m (c, d)) -> MonadArrow (->) m (b, d) (c, d)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m (b, d) -> ((b, d) -> m (c, d)) -> m (c, d)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ ~(b
a,d
c) -> ( ,d
c) (c -> (c, d)) -> m c -> m (c, d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m b -> m c
f (b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b
a))
  second :: forall b c d.
MonadArrow (->) m b c -> MonadArrow (->) m (d, b) (d, c)
second (MonadArrow m b -> m c
f) = (m (d, b) -> m (d, c)) -> MonadArrow (->) m (d, b) (d, c)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m (d, b) -> ((d, b) -> m (d, c)) -> m (d, c)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ ~(d
a,b
b) -> (d
a, ) (c -> (d, c)) -> m c -> m (d, c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m b -> m c
f (b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b
b))
  MonadArrow m b -> m c
f *** :: forall b c b' c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b' c' -> MonadArrow (->) m (b, b') (c, c')
*** MonadArrow m b' -> m c'
g = (m (b, b') -> m (c, c')) -> MonadArrow (->) m (b, b') (c, c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow
    (m (b, b') -> ((b, b') -> m (c, c')) -> m (c, c')
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ ~(b
a,b'
b) -> (,) (c -> c' -> (c, c')) -> m c -> m (c' -> (c, c'))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m b -> m c
f (b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b
a) m (c' -> (c, c')) -> m c' -> m (c, c')
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m b' -> m c'
g (b' -> m b'
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b'
b))
  MonadArrow m b -> m c
f &&& :: forall b c c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b c' -> MonadArrow (->) m b (c, c')
&&& MonadArrow m b -> m c'
g = (m b -> m (c, c')) -> MonadArrow (->) m b (c, c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow
    (m b -> (b -> m (c, c')) -> m (c, c')
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ b
a -> let ma :: m b
ma = b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b
a in (,) (c -> c' -> (c, c')) -> m c -> m (c' -> (c, c'))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m b -> m c
f m b
ma m (c' -> (c, c')) -> m c' -> m (c, c')
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m b -> m c'
g m b
ma)

instance Monad m => ArrowChoice (MonadArrow (->) m) where
  left :: forall b c d.
MonadArrow (->) m b c
-> MonadArrow (->) m (Either b d) (Either c d)
left  (MonadArrow m b -> m c
f) = (m (Either b d) -> m (Either c d))
-> MonadArrow (->) m (Either b d) (Either c d)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m (Either b d) -> (Either b d -> m (Either c d)) -> m (Either c d)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (b -> m (Either c d))
-> (d -> m (Either c d)) -> Either b d -> m (Either c d)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ((c -> Either c d) -> m c -> m (Either c d)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> Either c d
forall a b. a -> Either a b
Left (m c -> m (Either c d)) -> (b -> m c) -> b -> m (Either c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. m b -> m c
f (m b -> m c) -> (b -> m b) -> b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return) (Either c d -> m (Either c d)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either c d -> m (Either c d))
-> (d -> Either c d) -> d -> m (Either c d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. d -> Either c d
forall a b. b -> Either a b
Right))
  right :: forall b c d.
MonadArrow (->) m b c
-> MonadArrow (->) m (Either d b) (Either d c)
right (MonadArrow m b -> m c
f) = (m (Either d b) -> m (Either d c))
-> MonadArrow (->) m (Either d b) (Either d c)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m (Either d b) -> (Either d b -> m (Either d c)) -> m (Either d c)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (d -> m (Either d c))
-> (b -> m (Either d c)) -> Either d b -> m (Either d c)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either d c -> m (Either d c)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either d c -> m (Either d c))
-> (d -> Either d c) -> d -> m (Either d c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. d -> Either d c
forall a b. a -> Either a b
Left) ((c -> Either d c) -> m c -> m (Either d c)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> Either d c
forall a b. b -> Either a b
Right (m c -> m (Either d c)) -> (b -> m c) -> b -> m (Either d c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. m b -> m c
f (m b -> m c) -> (b -> m b) -> b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return))
  MonadArrow m b -> m c
f +++ :: forall b c b' c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b' c'
-> MonadArrow (->) m (Either b b') (Either c c')
+++ MonadArrow m b' -> m c'
g = (m (Either b b') -> m (Either c c'))
-> MonadArrow (->) m (Either b b') (Either c c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow
    (m (Either b b')
-> (Either b b' -> m (Either c c')) -> m (Either c c')
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (b -> m (Either c c'))
-> (b' -> m (Either c c')) -> Either b b' -> m (Either c c')
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ((c -> Either c c') -> m c -> m (Either c c')
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> Either c c'
forall a b. a -> Either a b
Left (m c -> m (Either c c')) -> (b -> m c) -> b -> m (Either c c')
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. m b -> m c
f (m b -> m c) -> (b -> m b) -> b -> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return) ((c' -> Either c c') -> m c' -> m (Either c c')
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c' -> Either c c'
forall a b. b -> Either a b
Right (m c' -> m (Either c c')) -> (b' -> m c') -> b' -> m (Either c c')
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. m b' -> m c'
g (m b' -> m c') -> (b' -> m b') -> b' -> m c'
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b' -> m b'
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return))
  MonadArrow m b -> m d
f ||| :: forall b d c.
MonadArrow (->) m b d
-> MonadArrow (->) m c d -> MonadArrow (->) m (Either b c) d
||| MonadArrow m c -> m d
g = (m (Either b c) -> m d) -> MonadArrow (->) m (Either b c) d
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow
    (m (Either b c) -> (Either b c -> m d) -> m d
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (b -> m d) -> (c -> m d) -> Either b c -> m d
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (m b -> m d
f (m b -> m d) -> (b -> m b) -> b -> m d
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return) (m c -> m d
g (m c -> m d) -> (c -> m c) -> c -> m d
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. c -> m c
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return))

instance MonadPlus m => ArrowZero (MonadArrow (->) m) where
  zeroArrow :: forall b c. MonadArrow (->) m b c
zeroArrow = (m b -> m c) -> MonadArrow (->) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m c -> m b -> m c
forall a b. a -> b -> a
const m c
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero)

instance MonadPlus m => ArrowPlus (MonadArrow (->) m) where
  MonadArrow m b -> m c
f <+> :: forall b c.
MonadArrow (->) m b c
-> MonadArrow (->) m b c -> MonadArrow (->) m b c
<+> MonadArrow m b -> m c
g = (m b -> m c) -> MonadArrow (->) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m b -> (b -> m c) -> m c
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \b
x -> let mx :: m b
mx = b -> m b
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return b
x in m b -> m c
f m b
mx m c -> m c -> m c
forall a. m a -> m a -> m a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` m b -> m c
g m b
mx)

liftMoA :: (MonadArrow (->) m a b -> MonadArrow (->) m c d) -> (m a -> m b) -> (m c -> m d)
liftMoA :: forall (m :: * -> *) a b c d.
(MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> (m a -> m b) -> m c -> m d
liftMoA MonadArrow (->) m a b -> MonadArrow (->) m c d
t = MonadArrow (->) m c d -> m c -> m d
forall (a :: * -> * -> *) (m :: * -> *) b c.
MonadArrow a m b c -> a (m b) (m c)
runMonadArrow (MonadArrow (->) m c d -> m c -> m d)
-> ((m a -> m b) -> MonadArrow (->) m c d)
-> (m a -> m b)
-> m c
-> m d
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. MonadArrow (->) m a b -> MonadArrow (->) m c d
t (MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> ((m a -> m b) -> MonadArrow (->) m a b)
-> (m a -> m b)
-> MonadArrow (->) m c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (m a -> m b) -> MonadArrow (->) m a b
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow

liftMoA2 :: (MonadArrow (->) m a b -> MonadArrow (->) m c d -> MonadArrow (->) m e f) -> (m a -> m b) -> (m c -> m d) -> (m e -> m f)
liftMoA2 :: forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m a b
-> MonadArrow (->) m c d -> MonadArrow (->) m e f
t m a -> m b
f m c -> m d
g = MonadArrow (->) m e f -> m e -> m f
forall (a :: * -> * -> *) (m :: * -> *) b c.
MonadArrow a m b c -> a (m b) (m c)
runMonadArrow ((m a -> m b) -> MonadArrow (->) m a b
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow m a -> m b
f MonadArrow (->) m a b
-> MonadArrow (->) m c d -> MonadArrow (->) m e f
`t` (m c -> m d) -> MonadArrow (->) m c d
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow m c -> m d
g)

instance Monad m => Arrow (MonadArrow (<->) m) where
  arr :: forall b c. (b -> c) -> MonadArrow (Bijection (->)) m b c
arr = (m b <-> m c) -> MonadArrow (Bijection (->)) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m b <-> m c) -> MonadArrow (Bijection (->)) m b c)
-> ((b -> c) -> m b <-> m c)
-> (b -> c)
-> MonadArrow (Bijection (->)) m b c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (m b -> m c) -> m b <-> m c
forall b c. (b -> c) -> Bijection (->) b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((m b -> m c) -> m b <-> m c)
-> ((b -> c) -> m b -> m c) -> (b -> c) -> m b <-> m c
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (b -> c) -> m b -> m c
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
  first :: forall b c d.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m (b, d) (c, d)
first (MonadArrow (m b -> m c
f :<->: m c -> m b
g)) = (m (b, d) <-> m (c, d))
-> MonadArrow (Bijection (->)) m (b, d) (c, d)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (b, d) <-> m (c, d))
 -> MonadArrow (Bijection (->)) m (b, d) (c, d))
-> (m (b, d) <-> m (c, d))
-> MonadArrow (Bijection (->)) m (b, d) (c, d)
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> m (b, d) -> m (c, d)
forall {a} {b} {d}. (m a -> m b) -> m (a, d) -> m (b, d)
bik m b -> m c
f (m (b, d) -> m (c, d))
-> (m (c, d) -> m (b, d)) -> m (b, d) <-> m (c, d)
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> m (c, d) -> m (b, d)
forall {a} {b} {d}. (m a -> m b) -> m (a, d) -> m (b, d)
bik m c -> m b
g
    where bik :: (m a -> m b) -> m (a, d) -> m (b, d)
bik = (MonadArrow (->) m a b -> MonadArrow (->) m (a, d) (b, d))
-> (m a -> m b) -> m (a, d) -> m (b, d)
forall (m :: * -> *) a b c d.
(MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> (m a -> m b) -> m c -> m d
liftMoA MonadArrow (->) m a b -> MonadArrow (->) m (a, d) (b, d)
forall b c d.
MonadArrow (->) m b c -> MonadArrow (->) m (b, d) (c, d)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first
  second :: forall b c d.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m (d, b) (d, c)
second (MonadArrow (m b -> m c
f :<->: m c -> m b
g)) = (m (d, b) <-> m (d, c))
-> MonadArrow (Bijection (->)) m (d, b) (d, c)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (d, b) <-> m (d, c))
 -> MonadArrow (Bijection (->)) m (d, b) (d, c))
-> (m (d, b) <-> m (d, c))
-> MonadArrow (Bijection (->)) m (d, b) (d, c)
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> m (d, b) -> m (d, c)
forall {a} {b} {d}. (m a -> m b) -> m (d, a) -> m (d, b)
bik m b -> m c
f (m (d, b) -> m (d, c))
-> (m (d, c) -> m (d, b)) -> m (d, b) <-> m (d, c)
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> m (d, c) -> m (d, b)
forall {a} {b} {d}. (m a -> m b) -> m (d, a) -> m (d, b)
bik m c -> m b
g
    where bik :: (m a -> m b) -> m (d, a) -> m (d, b)
bik = (MonadArrow (->) m a b -> MonadArrow (->) m (d, a) (d, b))
-> (m a -> m b) -> m (d, a) -> m (d, b)
forall (m :: * -> *) a b c d.
(MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> (m a -> m b) -> m c -> m d
liftMoA MonadArrow (->) m a b -> MonadArrow (->) m (d, a) (d, b)
forall b c d.
MonadArrow (->) m b c -> MonadArrow (->) m (d, b) (d, c)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second
  MonadArrow (m b -> m c
f :<->: m c -> m b
g) *** :: forall b c b' c'.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m b' c'
-> MonadArrow (Bijection (->)) m (b, b') (c, c')
*** MonadArrow (m b' -> m c'
f' :<->: m c' -> m b'
g') =
    (m (b, b') <-> m (c, c'))
-> MonadArrow (Bijection (->)) m (b, b') (c, c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (b, b') <-> m (c, c'))
 -> MonadArrow (Bijection (->)) m (b, b') (c, c'))
-> (m (b, b') <-> m (c, c'))
-> MonadArrow (Bijection (->)) m (b, b') (c, c')
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> (m b' -> m c') -> m (b, b') -> m (c, c')
forall {a} {b} {c} {d}.
(m a -> m b) -> (m c -> m d) -> m (a, c) -> m (b, d)
bik m b -> m c
f m b' -> m c'
f' (m (b, b') -> m (c, c'))
-> (m (c, c') -> m (b, b')) -> m (b, b') <-> m (c, c')
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> (m c' -> m b') -> m (c, c') -> m (b, b')
forall {a} {b} {c} {d}.
(m a -> m b) -> (m c -> m d) -> m (a, c) -> m (b, d)
bik m c -> m b
g m c' -> m b'
g'
    where bik :: (m a -> m b) -> (m c -> m d) -> m (a, c) -> m (b, d)
bik = (MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m (a, c) (b, d))
-> (m a -> m b) -> (m c -> m d) -> m (a, c) -> m (b, d)
forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m a b
-> MonadArrow (->) m c d -> MonadArrow (->) m (a, c) (b, d)
forall b c b' c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b' c' -> MonadArrow (->) m (b, b') (c, c')
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
(***)
  MonadArrow (m b -> m c
f :<->: m c -> m b
g) &&& :: forall b c c'.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m b c'
-> MonadArrow (Bijection (->)) m b (c, c')
&&& MonadArrow (m b -> m c'
f' :<->: m c' -> m b
_) =
    (m b <-> m (c, c')) -> MonadArrow (Bijection (->)) m b (c, c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m b <-> m (c, c')) -> MonadArrow (Bijection (->)) m b (c, c'))
-> (m b <-> m (c, c')) -> MonadArrow (Bijection (->)) m b (c, c')
forall a b. (a -> b) -> a -> b
$ (MonadArrow (->) m b c
 -> MonadArrow (->) m b c' -> MonadArrow (->) m b (c, c'))
-> (m b -> m c) -> (m b -> m c') -> m b -> m (c, c')
forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m b c
-> MonadArrow (->) m b c' -> MonadArrow (->) m b (c, c')
forall b c c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b c' -> MonadArrow (->) m b (c, c')
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
(&&&) m b -> m c
f m b -> m c'
f' (m b -> m (c, c')) -> (m (c, c') -> m b) -> m b <-> m (c, c')
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b
g (m c -> m b) -> (m (c, c') -> m c) -> m (c, c') -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (m (c, c') -> m c) -> m (c, c') -> m c
forall b c. (b -> c) -> b -> c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (((c, c') -> c) -> m (c, c') -> m c
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (c, c') -> c
forall a b. (a, b) -> a
fst)) -- (g' . arr snd)

instance Monad m => ArrowChoice (MonadArrow (<->) m) where
  left :: forall b c d.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m (Either b d) (Either c d)
left  (MonadArrow (m b -> m c
f :<->: m c -> m b
g)) = (m (Either b d) <-> m (Either c d))
-> MonadArrow (Bijection (->)) m (Either b d) (Either c d)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (Either b d) <-> m (Either c d))
 -> MonadArrow (Bijection (->)) m (Either b d) (Either c d))
-> (m (Either b d) <-> m (Either c d))
-> MonadArrow (Bijection (->)) m (Either b d) (Either c d)
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> m (Either b d) -> m (Either c d)
forall {a} {b} {d}.
(m a -> m b) -> m (Either a d) -> m (Either b d)
bik m b -> m c
f (m (Either b d) -> m (Either c d))
-> (m (Either c d) -> m (Either b d))
-> m (Either b d) <-> m (Either c d)
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> m (Either c d) -> m (Either b d)
forall {a} {b} {d}.
(m a -> m b) -> m (Either a d) -> m (Either b d)
bik m c -> m b
g
    where bik :: (m a -> m b) -> m (Either a d) -> m (Either b d)
bik = (MonadArrow (->) m a b
 -> MonadArrow (->) m (Either a d) (Either b d))
-> (m a -> m b) -> m (Either a d) -> m (Either b d)
forall (m :: * -> *) a b c d.
(MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> (m a -> m b) -> m c -> m d
liftMoA MonadArrow (->) m a b
-> MonadArrow (->) m (Either a d) (Either b d)
forall b c d.
MonadArrow (->) m b c
-> MonadArrow (->) m (Either b d) (Either c d)
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left
  right :: forall b c d.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m (Either d b) (Either d c)
right (MonadArrow (m b -> m c
f :<->: m c -> m b
g)) = (m (Either d b) <-> m (Either d c))
-> MonadArrow (Bijection (->)) m (Either d b) (Either d c)
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (Either d b) <-> m (Either d c))
 -> MonadArrow (Bijection (->)) m (Either d b) (Either d c))
-> (m (Either d b) <-> m (Either d c))
-> MonadArrow (Bijection (->)) m (Either d b) (Either d c)
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> m (Either d b) -> m (Either d c)
forall {a} {b} {d}.
(m a -> m b) -> m (Either d a) -> m (Either d b)
bik m b -> m c
f (m (Either d b) -> m (Either d c))
-> (m (Either d c) -> m (Either d b))
-> m (Either d b) <-> m (Either d c)
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> m (Either d c) -> m (Either d b)
forall {a} {b} {d}.
(m a -> m b) -> m (Either d a) -> m (Either d b)
bik m c -> m b
g
    where bik :: (m a -> m b) -> m (Either d a) -> m (Either d b)
bik = (MonadArrow (->) m a b
 -> MonadArrow (->) m (Either d a) (Either d b))
-> (m a -> m b) -> m (Either d a) -> m (Either d b)
forall (m :: * -> *) a b c d.
(MonadArrow (->) m a b -> MonadArrow (->) m c d)
-> (m a -> m b) -> m c -> m d
liftMoA MonadArrow (->) m a b
-> MonadArrow (->) m (Either d a) (Either d b)
forall b c d.
MonadArrow (->) m b c
-> MonadArrow (->) m (Either d b) (Either d c)
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either d b) (Either d c)
right
  MonadArrow (m b -> m c
f :<->: m c -> m b
g) +++ :: forall b c b' c'.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m b' c'
-> MonadArrow (Bijection (->)) m (Either b b') (Either c c')
+++ MonadArrow (m b' -> m c'
f' :<->: m c' -> m b'
g') =
    (m (Either b b') <-> m (Either c c'))
-> MonadArrow (Bijection (->)) m (Either b b') (Either c c')
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (Either b b') <-> m (Either c c'))
 -> MonadArrow (Bijection (->)) m (Either b b') (Either c c'))
-> (m (Either b b') <-> m (Either c c'))
-> MonadArrow (Bijection (->)) m (Either b b') (Either c c')
forall a b. (a -> b) -> a -> b
$ (m b -> m c)
-> (m b' -> m c') -> m (Either b b') -> m (Either c c')
forall {a} {b} {c} {d}.
(m a -> m b) -> (m c -> m d) -> m (Either a c) -> m (Either b d)
bik m b -> m c
f m b' -> m c'
f' (m (Either b b') -> m (Either c c'))
-> (m (Either c c') -> m (Either b b'))
-> m (Either b b') <-> m (Either c c')
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b)
-> (m c' -> m b') -> m (Either c c') -> m (Either b b')
forall {a} {b} {c} {d}.
(m a -> m b) -> (m c -> m d) -> m (Either a c) -> m (Either b d)
bik m c -> m b
g m c' -> m b'
g'
    where bik :: (m a -> m b) -> (m c -> m d) -> m (Either a c) -> m (Either b d)
bik = (MonadArrow (->) m a b
 -> MonadArrow (->) m c d
 -> MonadArrow (->) m (Either a c) (Either b d))
-> (m a -> m b) -> (m c -> m d) -> m (Either a c) -> m (Either b d)
forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m a b
-> MonadArrow (->) m c d
-> MonadArrow (->) m (Either a c) (Either b d)
forall b c b' c'.
MonadArrow (->) m b c
-> MonadArrow (->) m b' c'
-> MonadArrow (->) m (Either b b') (Either c c')
forall (a :: * -> * -> *) b c b' c'.
ArrowChoice a =>
a b c -> a b' c' -> a (Either b b') (Either c c')
(+++)
  MonadArrow (m b -> m d
f :<->: m d -> m b
g) ||| :: forall b d c.
MonadArrow (Bijection (->)) m b d
-> MonadArrow (Bijection (->)) m c d
-> MonadArrow (Bijection (->)) m (Either b c) d
||| MonadArrow (m c -> m d
f' :<->: m d -> m c
_) =
    (m (Either b c) <-> m d)
-> MonadArrow (Bijection (->)) m (Either b c) d
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m (Either b c) <-> m d)
 -> MonadArrow (Bijection (->)) m (Either b c) d)
-> (m (Either b c) <-> m d)
-> MonadArrow (Bijection (->)) m (Either b c) d
forall a b. (a -> b) -> a -> b
$ (MonadArrow (->) m b d
 -> MonadArrow (->) m c d -> MonadArrow (->) m (Either b c) d)
-> (m b -> m d) -> (m c -> m d) -> m (Either b c) -> m d
forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m b d
-> MonadArrow (->) m c d -> MonadArrow (->) m (Either b c) d
forall b d c.
MonadArrow (->) m b d
-> MonadArrow (->) m c d -> MonadArrow (->) m (Either b c) d
forall (a :: * -> * -> *) b d c.
ArrowChoice a =>
a b d -> a c d -> a (Either b c) d
(|||) m b -> m d
f m c -> m d
f' (m (Either b c) -> m d)
-> (m d -> m (Either b c)) -> m (Either b c) <-> m d
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: ((m b -> m (Either b c)) -> m b -> m (Either b c)
forall b c. (b -> c) -> b -> c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((b -> Either b c) -> m b -> m (Either b c)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either b c
forall a b. a -> Either a b
Left) (m b -> m (Either b c)) -> (m d -> m b) -> m d -> m (Either b c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. m d -> m b
g) -- (arr (fmap Right) . g)

instance MonadPlus m => ArrowZero (MonadArrow (<->) m) where
  zeroArrow :: forall b c. MonadArrow (Bijection (->)) m b c
zeroArrow = (m b <-> m c) -> MonadArrow (Bijection (->)) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (m c -> m b -> m c
forall a b. a -> b -> a
const m c
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero (m b -> m c) -> (m c -> m b) -> m b <-> m c
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: m b -> m c -> m b
forall a b. a -> b -> a
const m b
forall a. m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero)

instance MonadPlus m => ArrowPlus (MonadArrow (<->) m) where
  MonadArrow (m b -> m c
f1 :<->: m c -> m b
g1) <+> :: forall b c.
MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m b c
-> MonadArrow (Bijection (->)) m b c
<+> MonadArrow (m b -> m c
f2 :<->: m c -> m b
g2) =
    Bijection (->) (m b) (m c) -> MonadArrow (Bijection (->)) m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (Bijection (->) (m b) (m c) -> MonadArrow (Bijection (->)) m b c)
-> Bijection (->) (m b) (m c) -> MonadArrow (Bijection (->)) m b c
forall a b. (a -> b) -> a -> b
$ (m b -> m c) -> (m b -> m c) -> m b -> m c
forall {e} {f}. (m e -> m f) -> (m e -> m f) -> m e -> m f
bik m b -> m c
f1 m b -> m c
f2 (m b -> m c) -> (m c -> m b) -> Bijection (->) (m b) (m c)
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: (m c -> m b) -> (m c -> m b) -> m c -> m b
forall {e} {f}. (m e -> m f) -> (m e -> m f) -> m e -> m f
bik m c -> m b
g1 m c -> m b
g2
    where bik :: (m e -> m f) -> (m e -> m f) -> m e -> m f
bik = (MonadArrow (->) m e f
 -> MonadArrow (->) m e f -> MonadArrow (->) m e f)
-> (m e -> m f) -> (m e -> m f) -> m e -> m f
forall (m :: * -> *) a b c d e f.
(MonadArrow (->) m a b
 -> MonadArrow (->) m c d -> MonadArrow (->) m e f)
-> (m a -> m b) -> (m c -> m d) -> m e -> m f
liftMoA2 MonadArrow (->) m e f
-> MonadArrow (->) m e f -> MonadArrow (->) m e f
forall b c.
MonadArrow (->) m b c
-> MonadArrow (->) m b c -> MonadArrow (->) m b c
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
(<+>)

instance (BiArrow a, Monad m) => BiArrow (MonadArrow a m) where
  b -> c
f <-> :: forall b c. (b -> c) -> (c -> b) -> MonadArrow a m b c
<-> c -> b
g = a (m b) (m c) -> MonadArrow a m b c
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow ((m b -> m c) -> m b -> m c
forall b c. (b -> c) -> b -> c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((b -> c) -> m b -> m c
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> c
f) (m b -> m c) -> (m c -> m b) -> a (m b) (m c)
forall b c. (b -> c) -> (c -> b) -> a b c
forall (a :: * -> * -> *) b c.
BiArrow a =>
(b -> c) -> (c -> b) -> a b c
<-> (m c -> m b) -> m c -> m b
forall b c. (b -> c) -> b -> c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr ((c -> b) -> m c -> m b
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap c -> b
g))
  invert :: forall b c. MonadArrow a m b c -> MonadArrow a m c b
invert (MonadArrow a (m b) (m c)
f) = a (m c) (m b) -> MonadArrow a m c b
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (a (m b) (m c) -> a (m c) (m b)
forall b c. a b c -> a c b
forall (a :: * -> * -> *) b c. BiArrow a => a b c -> a c b
invert a (m b) (m c)
f)

instance Monad m => BiArrow' (MonadArrow (<->) m)

#ifdef VERSION_semigroupoids
instance Semigroupoid a => Semigroupoid (MonadArrow a m) where
  MonadArrow a (m j) (m k1)
f o :: forall j k1 i.
MonadArrow a m j k1 -> MonadArrow a m i j -> MonadArrow a m i k1
`o` MonadArrow a (m i) (m j)
g = a (m i) (m k1) -> MonadArrow a m i k1
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (a (m j) (m k1)
f a (m j) (m k1) -> a (m i) (m j) -> a (m i) (m k1)
forall j k1 i. a j k1 -> a i j -> a i k1
forall {k} (c :: k -> k -> *) (j :: k) (k1 :: k) (i :: k).
Semigroupoid c =>
c j k1 -> c i j -> c i k1
`o` a (m i) (m j)
g)

instance Groupoid a => Groupoid (MonadArrow a m) where
  inv :: forall a b. MonadArrow a m a b -> MonadArrow a m b a
inv (MonadArrow a (m a) (m b)
f) = a (m b) (m a) -> MonadArrow a m b a
forall (a :: * -> * -> *) (m :: * -> *) b c.
a (m b) (m c) -> MonadArrow a m b c
MonadArrow (a (m a) (m b) -> a (m b) (m a)
forall a b. a a b -> a b a
forall {k} (k1 :: k -> k -> *) (a :: k) (b :: k).
Groupoid k1 =>
k1 a b -> k1 b a
inv a (m a) (m b)
f)
#endif