{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Bifunctor.Linear.Internal.SymmetricMonoidal
( SymmetricMonoidal (..),
)
where
import Data.Bifunctor.Linear.Internal.Bifunctor
import Data.Kind (Type)
import Data.Void
import Prelude.Linear
class
Bifunctor m =>
SymmetricMonoidal (m :: Type -> Type -> Type) (u :: Type)
| m -> u,
u -> m
where
{-# MINIMAL swap, (rassoc | lassoc) #-}
rassoc :: (a `m` b) `m` c %1 -> a `m` (b `m` c)
rassoc = forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b c.
SymmetricMonoidal m u =>
m a (m b c) %1 -> m (m a b) c
lassoc forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b c.
SymmetricMonoidal m u =>
m a (m b c) %1 -> m (m a b) c
lassoc forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap
lassoc :: a `m` (b `m` c) %1 -> (a `m` b) `m` c
lassoc = forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b c.
SymmetricMonoidal m u =>
m (m a b) c %1 -> m a (m b c)
rassoc forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b c.
SymmetricMonoidal m u =>
m (m a b) c %1 -> m a (m b c)
rassoc forall b c a (q :: Multiplicity) (m :: Multiplicity)
(n :: Multiplicity).
(b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
. forall (m :: * -> * -> *) u a b.
SymmetricMonoidal m u =>
m a b %1 -> m b a
swap
swap :: a `m` b %1 -> b `m` a
instance SymmetricMonoidal (,) () where
swap :: forall a b. (a, b) %1 -> (b, a)
swap (a
x, b
y) = (b
y, a
x)
rassoc :: forall a b c. ((a, b), c) %1 -> (a, (b, c))
rassoc ((a
x, b
y), c
z) = (a
x, (b
y, c
z))
instance SymmetricMonoidal Either Void where
swap :: forall a b. Either a b %1 -> Either b a
swap = forall a c b. (a %1 -> c) -> (b %1 -> c) -> Either a b %1 -> c
either forall a b. b -> Either a b
Right forall a b. a -> Either a b
Left
rassoc :: forall a b c. Either (Either a b) c %1 -> Either a (Either b c)
rassoc (Left (Left a
x)) = forall a b. a -> Either a b
Left a
x
rassoc (Left (Right b
x)) = (forall a b. b -> Either a b
Right :: a %1 -> Either b a) (forall a b. a -> Either a b
Left b
x)
rassoc (Right c
x) = (forall a b. b -> Either a b
Right :: a %1 -> Either b a) (forall a b. b -> Either a b
Right c
x)