bifunctors-5.2: Bifunctors

Data.Bifoldable

Description

Synopsis

# Documentation

class Bifoldable p where Source

Minimal definition either `bifoldr` or `bifoldMap`

`Bifoldable` identifies foldable structures with two different varieties of elements. Common examples are `Either` and '(,)':

```instance Bifoldable Either where
bifoldMap f _ (Left  a) = f a
bifoldMap _ g (Right b) = g b

instance Bifoldable (,) where
bifoldr f g z (a, b) = f a (g b z)```

When defining more than the minimal set of definitions, one should ensure that the following identities hold:

````bifold` ≡ `bifoldMap` `id` `id`
`bifoldMap` f g ≡ `bifoldr` (`mappend` . f) (`mappend` . g) `mempty`
`bifoldr` f g z t ≡ `appEndo` (`bifoldMap` (Endo . f) (Endo . g) t) z
```

Minimal complete definition

Methods

bifold :: Monoid m => p m m -> m Source

Combines the elements of a structure using a monoid.

``bifold` ≡ `bifoldMap` `id` `id``

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> p a b -> m Source

Combines the elements of a structure, given ways of mapping them to a common monoid.

``bifoldMap` f g ≡ `bifoldr` (`mappend` . f) (`mappend` . g) `mempty``

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c Source

Combines the elements of a structure in a right associative manner. Given a hypothetical function `toEitherList :: p a b -> [Either a b]` yielding a list of all elements of a structure in order, the following would hold:

``bifoldr` f g z ≡ `foldr` (`either` f g) z . toEitherList`

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c Source

Combines the elments of a structure in a left associative manner. Given a hypothetical function `toEitherList :: p a b -> [Either a b]` yielding a list of all elements of a structure in order, the following would hold:

``bifoldl` f g z ≡ `foldl` (acc -> `either` (f acc) (g acc)) z .  toEitherList`

Instances

 Source Methodsbifold :: Monoid m => Either m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Either a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Either a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Either a b -> c Source Source Methodsbifold :: Monoid m => (m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (a, b) -> c Source Source Methodsbifold :: Monoid m => Const m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Const a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Const a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Const a b -> c Source Source Methodsbifold :: Monoid m => Arg m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Arg a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Arg a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Arg a b -> c Source Source Methodsbifold :: Monoid m => (x, m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, a, b) -> c Source Source Methodsbifold :: Monoid m => Tagged * m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged * a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged * a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged * a b -> c Source Bifoldable ((,,,) x y) Source Methodsbifold :: Monoid m => (x, y, m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, a, b) -> c Source Bifoldable ((,,,,) x y z) Source Methodsbifold :: Monoid m => (x, y, z, m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, a, b) -> c Source Foldable f => Bifoldable (Clown * * f) Source Methodsbifold :: Monoid m => Clown * * f m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Clown * * f a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Clown * * f a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Clown * * f a b -> c Source Bifoldable p => Bifoldable (Flip * * p) Source Methodsbifold :: Monoid m => Flip * * p m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Flip * * p a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Flip * * p a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Flip * * p a b -> c Source Foldable g => Bifoldable (Joker * * g) Source Methodsbifold :: Monoid m => Joker * * g m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Joker * * g a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Joker * * g a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Joker * * g a b -> c Source Bifoldable p => Bifoldable (WrappedBifunctor * * p) Source Methodsbifold :: Monoid m => WrappedBifunctor * * p m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> WrappedBifunctor * * p a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> WrappedBifunctor * * p a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> WrappedBifunctor * * p a b -> c Source Bifoldable ((,,,,,) x y z w) Source Methodsbifold :: Monoid m => (x, y, z, w, m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, w, a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, w, a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, w, a, b) -> c Source (Bifoldable p, Bifoldable q) => Bifoldable (Sum * * p q) Source Methodsbifold :: Monoid m => Sum * * p q m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Sum * * p q a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Sum * * p q a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Sum * * p q a b -> c Source (Bifoldable f, Bifoldable g) => Bifoldable (Product * * f g) Source Methodsbifold :: Monoid m => Product * * f g m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Product * * f g a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Product * * f g a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Product * * f g a b -> c Source Bifoldable ((,,,,,,) x y z w v) Source Methodsbifold :: Monoid m => (x, y, z, w, v, m, m) -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> (x, y, z, w, v, a, b) -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> (x, y, z, w, v, a, b) -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> (x, y, z, w, v, a, b) -> c Source (Foldable f, Bifoldable p) => Bifoldable (Tannen * * * f p) Source Methodsbifold :: Monoid m => Tannen * * * f p m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tannen * * * f p a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tannen * * * f p a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tannen * * * f p a b -> c Source (Bifoldable p, Foldable f, Foldable g) => Bifoldable (Biff * * * * p f g) Source Methodsbifold :: Monoid m => Biff * * * * p f g m m -> m SourcebifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Biff * * * * p f g a b -> m Sourcebifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Biff * * * * p f g a b -> c Sourcebifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Biff * * * * p f g a b -> c Source

bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c Source

As `bifoldr`, but strict in the result of the reduction functions at each step.

bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c Source

Right associative monadic bifold over a structure.

bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a Source

As `bifoldl`, but strict in the result of the reductionf unctions at each step.

bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a Source

Left associative monadic bifold over a structure.

bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () Source

As `bitraverse`, but ignores the results of the functions, merely performing the "actions".

bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () Source

As `bitraverse_`, but with the structure as the primary argument.

bimapM_ :: (Bifoldable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m () Source

As `bimapM`, but ignores the results of the functions, merely performing the "actions".

biforM_ :: (Bifoldable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m () Source

As `bimapM_`, but with the structure as the primary argument.

bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () Source

As `bisequenceA`, but ignores the results of the actions.

bisequence_ :: (Bifoldable t, Monad m) => t (m a) (m b) -> m () Source

As `bisequence`, but ignores the results of the actions.

biList :: Bifoldable t => t a a -> [a] Source

Collects the list of elements of a structure in order.

biconcat :: Bifoldable t => t [a] [a] -> [a] Source

Reduces a structure of lists to the concatenation of those lists.

biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c] Source

Given a means of mapping the elements of a structure to lists, computes the concatenation of all such lists in order.

biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool Source

Determines whether any element of the structure satisfies the appropriate predicate.

biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool Source

Determines whether all elements of the structure satisfy the appropriate predicate.