assoc-1.0.2: swap and assoc: Symmetric and Semigroupy Bifunctors
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Bifunctor.Swap

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

Documentation

class Swap p where #

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 #

Instances

Instances details
Swap Either # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Either a b -> Either b a #

Swap (,) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (a, b) -> (b, a) #

Swap ((,,) x) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, a, b) -> (x, b, a) #

Swap ((,,,) x y) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, a, b) -> (x, y, b, a) #

Swap ((,,,,) x y z) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, a, b) -> (x, y, z, b, a) #

Swap p => Swap (Flip p) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

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

Swap ((,,,,,) x y z w) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, w, a, b) -> (x, y, z, w, b, a) #

(Swap p, Swap q) => Swap (Sum p q) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Sum p q a b -> Sum p q b a #

(Swap p, Swap q) => Swap (Product p q) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Product p q a b -> Product p q b a #

Swap ((,,,,,,) x y z w v) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, w, v, a, b) -> (x, y, z, w, v, b, a) #

(Functor f, Swap p) => Swap (Tannen f p) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Tannen f p a b -> Tannen f p b a #

(f ~ g, Functor f, Swap p) => Swap (Biff p f g) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Biff p f g a b -> Biff p f g b a #