semigroupoids-5.1: Semigroupoids: Category sans id

Copyright | (C) 2011-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.Bifunctor.Apply

Contents

- Biappliable bifunctors

Description

Synopsis

- class Bifunctor p where
  - bimap :: (a -> b) -> (c -> d) -> p a c -> p b d
  - first :: (a -> b) -> p a c -> p b c
  - second :: (b -> c) -> p a b -> p a c
- class Bifunctor p => Biapply p where
- (<<$>>) :: (a -> b) -> a -> b
- (<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d
- bilift2 :: Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f
- bilift3 :: Biapply w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h

# Biappliable bifunctors

class Bifunctor p where #

Formally, the class `Bifunctor` represents a bifunctor from `Hask` -> `Hask`.

Intuitively it is a bifunctor where both the first and second arguments are covariant.

You can define a `Bifunctor` by either defining `bimap` or by defining both `first` and `second`.

If you supply `bimap`, you should ensure that:

    bimap id id ≡ id

If you supply `first` and `second`, ensure:

    first id ≡ id
    second id ≡ id

If you supply both, you should also ensure:

    bimap f g ≡ first f . second g

These ensure by parametricity:

    bimap  (f . g) (h . i) ≡ bimap f h . bimap g i
    first  (f . g) ≡ first  f . first  g
    second (f . g) ≡ second f . second g

Since: 4.8.0.0

Minimal complete definition

bimap | first, second

Instances

Bifunctor Either |
Methods bimap :: (a -> b) -> (c -> d) -> Either a c -> Either b d # first :: (a -> b) -> Either a c -> Either b c # second :: (b -> c) -> Either a b -> Either a c #
Bifunctor (,) |
Methods bimap :: (a -> b) -> (c -> d) -> (a, c) -> (b, d) # first :: (a -> b) -> (a, c) -> (b, c) # second :: (b -> c) -> (a, b) -> (a, c) #
Bifunctor Arg |
Methods bimap :: (a -> b) -> (c -> d) -> Arg a c -> Arg b d # first :: (a -> b) -> Arg a c -> Arg b c # second :: (b -> c) -> Arg a b -> Arg a c #
Bifunctor (K1 i) |
Methods bimap :: (a -> b) -> (c -> d) -> K1 i a c -> K1 i b d # first :: (a -> b) -> K1 i a c -> K1 i b c # second :: (b -> c) -> K1 i a b -> K1 i a c #
Bifunctor ((,,) x1) |
Methods bimap :: (a -> b) -> (c -> d) -> (x1, a, c) -> (x1, b, d) # first :: (a -> b) -> (x1, a, c) -> (x1, b, c) # second :: (b -> c) -> (x1, a, b) -> (x1, a, c) #
Bifunctor (Const *) |
Methods bimap :: (a -> b) -> (c -> d) -> Const * a c -> Const * b d # first :: (a -> b) -> Const * a c -> Const * b c # second :: (b -> c) -> Const * a b -> Const * a c #
Bifunctor (Tagged *) |
Methods bimap :: (a -> b) -> (c -> d) -> Tagged * a c -> Tagged * b d # first :: (a -> b) -> Tagged * a c -> Tagged * b c # second :: (b -> c) -> Tagged * a b -> Tagged * a c #
Bifunctor (Constant *) |
Methods bimap :: (a -> b) -> (c -> d) -> Constant * a c -> Constant * b d # first :: (a -> b) -> Constant * a c -> Constant * b c # second :: (b -> c) -> Constant * a b -> Constant * a c #
Bifunctor ((,,,) x1 x2) |
Methods bimap :: (a -> b) -> (c -> d) -> (x1, x2, a, c) -> (x1, x2, b, d) # first :: (a -> b) -> (x1, x2, a, c) -> (x1, x2, b, c) # second :: (b -> c) -> (x1, x2, a, b) -> (x1, x2, a, c) #
Bifunctor ((,,,,) x1 x2 x3) |
Methods bimap :: (a -> b) -> (c -> d) -> (x1, x2, x3, a, c) -> (x1, x2, x3, b, d) # first :: (a -> b) -> (x1, x2, x3, a, c) -> (x1, x2, x3, b, c) # second :: (b -> c) -> (x1, x2, x3, a, b) -> (x1, x2, x3, a, c) #
Bifunctor p => Bifunctor (WrappedBifunctor * * p) |
Methods bimap :: (a -> b) -> (c -> d) -> WrappedBifunctor * * p a c -> WrappedBifunctor * * p b d # first :: (a -> b) -> WrappedBifunctor * * p a c -> WrappedBifunctor * * p b c # second :: (b -> c) -> WrappedBifunctor * * p a b -> WrappedBifunctor * * p a c #
Functor g => Bifunctor (Joker * * g) |
Methods bimap :: (a -> b) -> (c -> d) -> Joker * * g a c -> Joker * * g b d # first :: (a -> b) -> Joker * * g a c -> Joker * * g b c # second :: (b -> c) -> Joker * * g a b -> Joker * * g a c #
Bifunctor p => Bifunctor (Flip * * p) |
Methods bimap :: (a -> b) -> (c -> d) -> Flip * * p a c -> Flip * * p b d # first :: (a -> b) -> Flip * * p a c -> Flip * * p b c # second :: (b -> c) -> Flip * * p a b -> Flip * * p a c #
Functor f => Bifunctor (Clown * * f) |
Methods bimap :: (a -> b) -> (c -> d) -> Clown * * f a c -> Clown * * f b d # first :: (a -> b) -> Clown * * f a c -> Clown * * f b c # second :: (b -> c) -> Clown * * f a b -> Clown * * f a c #
Bifunctor ((,,,,,) x1 x2 x3 x4) |
Methods bimap :: (a -> b) -> (c -> d) -> (x1, x2, x3, x4, a, c) -> (x1, x2, x3, x4, b, d) # first :: (a -> b) -> (x1, x2, x3, x4, a, c) -> (x1, x2, x3, x4, b, c) # second :: (b -> c) -> (x1, x2, x3, x4, a, b) -> (x1, x2, x3, x4, a, c) #
(Bifunctor f, Bifunctor g) => Bifunctor (Product * * f g) |
Methods bimap :: (a -> b) -> (c -> d) -> Product * * f g a c -> Product * * f g b d # first :: (a -> b) -> Product * * f g a c -> Product * * f g b c # second :: (b -> c) -> Product * * f g a b -> Product * * f g a c #
Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) |
Methods bimap :: (a -> b) -> (c -> d) -> (x1, x2, x3, x4, x5, a, c) -> (x1, x2, x3, x4, x5, b, d) # first :: (a -> b) -> (x1, x2, x3, x4, x5, a, c) -> (x1, x2, x3, x4, x5, b, c) # second :: (b -> c) -> (x1, x2, x3, x4, x5, a, b) -> (x1, x2, x3, x4, x5, a, c) #
(Functor f, Bifunctor p) => Bifunctor (Tannen * * * f p) |
Methods bimap :: (a -> b) -> (c -> d) -> Tannen * * * f p a c -> Tannen * * * f p b d # first :: (a -> b) -> Tannen * * * f p a c -> Tannen * * * f p b c # second :: (b -> c) -> Tannen * * * f p a b -> Tannen * * * f p a c #
(Bifunctor p, Functor f, Functor g) => Bifunctor (Biff * * * * p f g) |
Methods bimap :: (a -> b) -> (c -> d) -> Biff * * * * p f g a c -> Biff * * * * p f g b d # first :: (a -> b) -> Biff * * * * p f g a c -> Biff * * * * p f g b c # second :: (b -> c) -> Biff * * * * p f g a b -> Biff * * * * p f g a c #

class Bifunctor p => Biapply p where #

Minimal complete definition

(<<.>>)

Methods

(<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d infixl 4 #

(.>>) :: p a b -> p c d -> p c d infixl 4 #

    a .> b ≡ const id <$> a <.> b

(<<.) :: p a b -> p c d -> p a b infixl 4 #

    a <. b ≡ const <$> a <.> b

Instances

Biapply (,) # |
Methods (<<.>>) :: (a -> b, c -> d) -> (a, c) -> (b, d) # (.>>) :: (a, b) -> (c, d) -> (c, d) # (<<.) :: (a, b) -> (c, d) -> (a, b) #
Biapply Arg # |
Methods (<<.>>) :: Arg (a -> b) (c -> d) -> Arg a c -> Arg b d # (.>>) :: Arg a b -> Arg c d -> Arg c d # (<<.) :: Arg a b -> Arg c d -> Arg a b #
Semigroup x => Biapply ((,,) x) # |
Methods (<<.>>) :: (x, a -> b, c -> d) -> (x, a, c) -> (x, b, d) # (.>>) :: (x, a, b) -> (x, c, d) -> (x, c, d) # (<<.) :: (x, a, b) -> (x, c, d) -> (x, a, b) #
Biapply (Const *) # |
Methods (<<.>>) :: Const * (a -> b) (c -> d) -> Const * a c -> Const * b d # (.>>) :: Const * a b -> Const * c d -> Const * c d # (<<.) :: Const * a b -> Const * c d -> Const * a b #
Biapply (Tagged *) # |
Methods (<<.>>) :: Tagged * (a -> b) (c -> d) -> Tagged * a c -> Tagged * b d # (.>>) :: Tagged * a b -> Tagged * c d -> Tagged * c d # (<<.) :: Tagged * a b -> Tagged * c d -> Tagged * a b #
(Semigroup x, Semigroup y) => Biapply ((,,,) x y) # |
Methods (<<.>>) :: (x, y, a -> b, c -> d) -> (x, y, a, c) -> (x, y, b, d) # (.>>) :: (x, y, a, b) -> (x, y, c, d) -> (x, y, c, d) # (<<.) :: (x, y, a, b) -> (x, y, c, d) -> (x, y, a, b) #
(Semigroup x, Semigroup y, Semigroup z) => Biapply ((,,,,) x y z) # |
Methods (<<.>>) :: (x, y, z, a -> b, c -> d) -> (x, y, z, a, c) -> (x, y, z, b, d) # (.>>) :: (x, y, z, a, b) -> (x, y, z, c, d) -> (x, y, z, c, d) # (<<.) :: (x, y, z, a, b) -> (x, y, z, c, d) -> (x, y, z, a, b) #
Biapply p => Biapply (WrappedBifunctor * * p) # |
Methods (<<.>>) :: WrappedBifunctor * * p (a -> b) (c -> d) -> WrappedBifunctor * * p a c -> WrappedBifunctor * * p b d # (.>>) :: WrappedBifunctor * * p a b -> WrappedBifunctor * * p c d -> WrappedBifunctor * * p c d # (<<.) :: WrappedBifunctor * * p a b -> WrappedBifunctor * * p c d -> WrappedBifunctor * * p a b #
Apply g => Biapply (Joker * * g) # |
Methods (<<.>>) :: Joker * * g (a -> b) (c -> d) -> Joker * * g a c -> Joker * * g b d # (.>>) :: Joker * * g a b -> Joker * * g c d -> Joker * * g c d # (<<.) :: Joker * * g a b -> Joker * * g c d -> Joker * * g a b #
Biapply p => Biapply (Flip * * p) # |
Methods (<<.>>) :: Flip * * p (a -> b) (c -> d) -> Flip * * p a c -> Flip * * p b d # (.>>) :: Flip * * p a b -> Flip * * p c d -> Flip * * p c d # (<<.) :: Flip * * p a b -> Flip * * p c d -> Flip * * p a b #
Apply f => Biapply (Clown * * f) # |
Methods (<<.>>) :: Clown * * f (a -> b) (c -> d) -> Clown * * f a c -> Clown * * f b d # (.>>) :: Clown * * f a b -> Clown * * f c d -> Clown * * f c d # (<<.) :: Clown * * f a b -> Clown * * f c d -> Clown * * f a b #
(Biapply p, Biapply q) => Biapply (Product * * p q) # |
Methods (<<.>>) :: Product * * p q (a -> b) (c -> d) -> Product * * p q a c -> Product * * p q b d # (.>>) :: Product * * p q a b -> Product * * p q c d -> Product * * p q c d # (<<.) :: Product * * p q a b -> Product * * p q c d -> Product * * p q a b #
(Apply f, Biapply p) => Biapply (Tannen * * * f p) # |
Methods (<<.>>) :: Tannen * * * f p (a -> b) (c -> d) -> Tannen * * * f p a c -> Tannen * * * f p b d # (.>>) :: Tannen * * * f p a b -> Tannen * * * f p c d -> Tannen * * * f p c d # (<<.) :: Tannen * * * f p a b -> Tannen * * * f p c d -> Tannen * * * f p a b #
(Biapply p, Apply f, Apply g) => Biapply (Biff * * * * p f g) # |
Methods (<<.>>) :: Biff * * * * p f g (a -> b) (c -> d) -> Biff * * * * p f g a c -> Biff * * * * p f g b d # (.>>) :: Biff * * * * p f g a b -> Biff * * * * p f g c d -> Biff * * * * p f g c d # (<<.) :: Biff * * * * p f g a b -> Biff * * * * p f g c d -> Biff * * * * p f g a b #

(<<$>>) :: (a -> b) -> a -> b infixl 4 #

(<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d infixl 4 #

bilift2 :: Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f #

Lift binary functions

bilift3 :: Biapply w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h #

Lift ternary functions