Portability | portable |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Inferred |

- class Bifoldable p where
- bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c
- bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c
- bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a
- bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a
- bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()
- bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()
- bimapM_ :: (Bifoldable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m ()
- biforM_ :: (Bifoldable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m ()
- bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()
- bisequence_ :: (Bifoldable t, Monad m) => t (m a) (m b) -> m ()
- biList :: Bifoldable t => t a a -> [a]
- biconcat :: Bifoldable t => t [a] [a] -> [a]
- biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c]
- biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

# Documentation

class Bifoldable p whereSource

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

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

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

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 -> cSource

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 -> cSource

Bifoldable Either | |

Bifoldable (,) | |

Bifoldable Const | |

Bifoldable ((,,) x) | |

Bifoldable (Tagged *) | |

Foldable f => Bifoldable (Clown f) | |

Bifoldable p => Bifoldable (Flip p) | |

Foldable g => Bifoldable (Joker g) | |

Bifoldable p => Bifoldable (WrappedBifunctor p) | |

Bifoldable ((,,,) x y) | |

(Bifoldable f, Bifoldable g) => Bifoldable (Product f g) | |

Bifoldable ((,,,,) x y z) |

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

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 cSource

Right associative monadic bifold over a structure.

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

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 aSource

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

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.