linear-base-0.1.0: Standard library for linear types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Bifunctor.Linear.Internal.SymmetricMonoidal

Synopsis

Documentation

class Bifunctor m => SymmetricMonoidal (m :: Type -> Type -> Type) (u :: Type) | m -> u, u -> m where Source #

A SymmetricMonoidal class

This allows you to shuffle around a bifunctor nested in itself and swap the places of the two types held in the bifunctor. For instance, for tuples:

  • You can use lassoc :: (a,(b,c)) %1-> ((a,b),c) and then use first to access the a
  • You can use the dual, i.e., rassoc :: ((a,b),c) %1-> (a,(b,c)) and then second
  • You can swap the first and second values with swap :: (a,b) %1-> (b,a)

Laws

  • swap . swap = id
  • rassoc . lassoc = id
  • lassoc . rassoc = id
  • second swap . rassoc . first swap = rassoc . swap . rassoc

Minimal complete definition

swap, (rassoc | lassoc)

Methods

rassoc :: ((a `m` b) `m` c) %1 -> a `m` (b `m` c) Source #

lassoc :: (a `m` (b `m` c)) %1 -> (a `m` b) `m` c Source #

swap :: (a `m` b) %1 -> b `m` a Source #

Instances

Instances details
SymmetricMonoidal Either Void Source # 
Instance details

Defined in Data.Bifunctor.Linear.Internal.SymmetricMonoidal

Methods

rassoc :: Either (Either a b) c %1 -> Either a (Either b c) Source #

lassoc :: Either a (Either b c) %1 -> Either (Either a b) c Source #

swap :: Either a b %1 -> Either b a Source #

SymmetricMonoidal (,) () Source # 
Instance details

Defined in Data.Bifunctor.Linear.Internal.SymmetricMonoidal

Methods

rassoc :: ((a, b), c) %1 -> (a, (b, c)) Source #

lassoc :: (a, (b, c)) %1 -> ((a, b), c) Source #

swap :: (a, b) %1 -> (b, a) Source #