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 |

- class Bifoldable p where
- bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c
- bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a
- 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
- bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> 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 ()
- bimsum :: (Bifoldable t, MonadPlus m) => t (m a) (m a) -> m a
- bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()
- bisequence_ :: (Bifoldable t, Monad m) => t (m a) (m b) -> m ()
- biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a
- biList :: Bifoldable t => t a a -> [a]
- binull :: Bifoldable t => t a b -> Bool
- bilength :: Bifoldable t => t a b -> Int
- bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool
- bimaximum :: forall t a. (Bifoldable t, Ord a) => t a a -> a
- biminimum :: forall t a. (Bifoldable t, Ord a) => t a a -> a
- bisum :: (Bifoldable t, Num a) => t a a -> a
- biproduct :: (Bifoldable t, Num a) => t a a -> a
- biconcat :: Bifoldable t => t [a] [a] -> [a]
- biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c]
- biand :: Bifoldable t => t Bool Bool -> Bool
- bior :: Bifoldable t => t Bool Bool -> Bool
- biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a
- biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a
- binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool
- bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a

# 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

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

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

Bifoldable Either Source | |

Bifoldable (,) Source | |

Bifoldable Const Source | |

Bifoldable Arg Source | |

Bifoldable Constant Source | |

Bifoldable (K1 i) Source | |

Bifoldable ((,,) x) Source | |

Bifoldable (Tagged *) Source | |

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

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

Foldable f => Bifoldable (Clown * * f) Source | |

Bifoldable p => Bifoldable (Flip * * p) Source | |

Foldable g => Bifoldable (Joker * * g) Source | |

Bifoldable p => Bifoldable (WrappedBifunctor * * p) Source | |

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

(Bifoldable p, Bifoldable q) => Bifoldable (Sum * * p q) Source | |

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

Bifoldable ((,,,,,,) x y z w v) Source | |

(Foldable f, Bifoldable p) => Bifoldable (Tannen * * * f p) Source | |

(Bifoldable p, Foldable f, Foldable g) => Bifoldable (Biff * * * * p f g) 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.

bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a Source

A variant of `bifoldr`

that has no base case,
and thus may only be applied to non-empty structures.

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.

bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> a Source

A variant of `bifoldl`

that has no base case,
and thus may only be applied to non-empty structures.

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.

bimsum :: (Bifoldable t, MonadPlus m) => t (m a) (m a) -> m a Source

The sum of a collection of actions, generalizing `biconcat`

.

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.

biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a Source

The sum of a collection of actions, generalizing `biconcat`

.

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

Collects the list of elements of a structure in order.

binull :: Bifoldable t => t a b -> Bool Source

Test whether the structure is empty.

bilength :: Bifoldable t => t a b -> Int Source

Returns the size/length of a finite structure as an `Int`

.

bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool Source

Does the element occur in the structure?

bimaximum :: forall t a. (Bifoldable t, Ord a) => t a a -> a Source

The largest element of a non-empty structure.

biminimum :: forall t a. (Bifoldable t, Ord a) => t a a -> a Source

The least element of a non-empty structure.

bisum :: (Bifoldable t, Num a) => t a a -> a Source

The `bisum`

function computes the sum of the numbers of a structure.

biproduct :: (Bifoldable t, Num a) => t a a -> a Source

The `biproduct`

function computes the product of the numbers of a
structure.

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.

bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a Source

The largest element of a non-empty structure with respect to the given comparison function.

biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a Source

The least element of a non-empty structure with respect to the given comparison function.