assoc-1: swap and assoc: Symmetric and Semigroupy Bifunctors

Data.Bifunctor.Swap

Synopsis
• class Swap p where
• swap :: p a b -> p b a

Documentation

class Swap p where Source #

Symmetric Bifunctors.

swap . swap = id


If p is a Bifunctor the following property is assumed to hold:

swap . bimap f g = bimap g f . swap


Swap isn't a subclass of Bifunctor, as for example

>>> newtype Bipredicate a b = Bipredicate (a -> b -> Bool)


is not a Bifunctor but has Swap instance

>>> instance Swap Bipredicate where swap (Bipredicate p) = Bipredicate (flip p)


Methods

swap :: p a b -> p b a Source #

Instances
 Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Either a b -> Either b a Source # Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: (a, b) -> (b, a) Source # Swap p => Swap (Flip p) Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Flip p a b -> Flip p b a Source # (Swap p, Swap q) => Swap (Sum p q) Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Sum p q a b -> Sum p q b a Source # (Swap p, Swap q) => Swap (Product p q) Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Product p q a b -> Product p q b a Source # (Functor f, Swap p) => Swap (Tannen f p) Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Tannen f p a b -> Tannen f p b a Source # (f ~ g, Functor f, Swap p) => Swap (Biff p f g) Source # Instance detailsDefined in Data.Bifunctor.Swap Methodsswap :: Biff p f g a b -> Biff p f g b a Source #