| Copyright | Ross Paterson 2005 |
|---|---|
| License | BSD-style (see the LICENSE file in the distribution) |
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Data.Foldable
Contents
Description
Class of data structures that can be folded to a summary value.
Data structures that can be folded.
For example, given a data type
data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
a suitable instance would be
instance Foldable Tree where foldMap f Empty = mempty foldMap f (Leaf x) = f x foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
This is suitable even for abstract types, as the monoid is assumed to satisfy the monoid laws. Alternatively, one could definefoldr:
instance Foldable Tree where foldr f z Empty = z foldr f z (Leaf x) = f x z foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
Foldable instances are expected to satisfy the following laws:
foldr f z t = appEndo (foldMap (Endo . f) t ) z
foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
fold = foldMap id
length = getSum . foldMap (Sum . const 1)
sum,product,maximum, andminimum should all be essentially equivalent tofoldMap forms, such as
sum = getSum . foldMap Sum
but may be less defined.
If the type is also aFunctor instance, it should satisfy
foldMap f = fold . fmap f
which implies that
foldMap f . fmap g = foldMap (f . g)
Methods
fold ::Monoid m => t m -> mSource#
Combine the elements of a structure using a monoid.
foldMap ::Monoid m => (a -> m) -> t a -> mSource#
Map each element of the structure to a monoid, and combine the results.
foldr :: (a -> b -> b) -> b -> t a -> bSource#
Right-associative fold of a structure.
In the case of lists,foldr, when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list,foldr can produce a terminating expression from an infinite list.
For a generalFoldable structure this should be semantically identical to,
foldr f z =foldrf z .toList
foldr' :: (a -> b -> b) -> b -> t a -> bSource#
Right-associative fold of a structure, but with strict application of the operator.
foldl :: (b -> a -> b) -> b -> t a -> bSource#
Left-associative fold of a structure.
In the case of lists,foldl, when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the entire input list must be traversed. This means thatfoldl' will diverge if given an infinite list.
Also note that if you want an efficient left-fold, you probably want to usefoldl' instead offoldl. The reason for this is that latter does not force the "inner" results (e.g.z in the above example) before applying them to the operator (e.g. tof x1(). This results in a thunk chainf x2)O(n) elements long, which then must be evaluated from the outside-in.
For a generalFoldable structure this should be semantically identical to,
foldl f z =foldlf z .toList
foldl' :: (b -> a -> b) -> b -> t a -> bSource#
Left-associative fold of a structure but with strict application of the operator.
This ensures that each step of the fold is forced to weak head normal form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite list to a single, monolithic result (e.g.length).
For a generalFoldable structure this should be semantically identical to,
foldl f z =foldl'f z .toList
foldr1 :: (a -> a -> a) -> t a -> aSource#
A variant offoldr that has no base case, and thus may only be applied to non-empty structures.
foldr1f =foldr1f .toList
foldl1 :: (a -> a -> a) -> t a -> aSource#
A variant offoldl that has no base case, and thus may only be applied to non-empty structures.
foldl1f =foldl1f .toList
List of elements of a structure, from left to right.
Test whether the structure is empty. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.
Returns the size/length of a finite structure as anInt. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.
elem ::Eq a => a -> t a ->Boolinfix 4Source#
Does the element occur in the structure?
maximum ::forall a.Ord a => t a -> aSource#
The largest element of a non-empty structure.
minimum ::forall a.Ord a => t a -> aSource#
The least element of a non-empty structure.
sum ::Num a => t a -> aSource#
Thesum function computes the sum of the numbers of a structure.
product ::Num a => t a -> aSource#
Theproduct function computes the product of the numbers of a structure.
| Foldable []Source# | Since: 2.1 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m => [m] -> mSource# foldMap ::Monoid m => (a -> m) -> [a] -> mSource# foldr :: (a -> b -> b) -> b -> [a] -> bSource# foldr' :: (a -> b -> b) -> b -> [a] -> bSource# foldl :: (b -> a -> b) -> b -> [a] -> bSource# foldl' :: (b -> a -> b) -> b -> [a] -> bSource# foldr1 :: (a -> a -> a) -> [a] -> aSource# foldl1 :: (a -> a -> a) -> [a] -> aSource# elem ::Eq a => a -> [a] ->BoolSource# maximum ::Ord a => [a] -> aSource# minimum ::Ord a => [a] -> aSource# | |
| FoldableMaybeSource# | Since: 2.1 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Maybe m -> mSource# foldMap ::Monoid m => (a -> m) ->Maybe a -> mSource# foldr :: (a -> b -> b) -> b ->Maybe a -> bSource# foldr' :: (a -> b -> b) -> b ->Maybe a -> bSource# foldl :: (b -> a -> b) -> b ->Maybe a -> bSource# foldl' :: (b -> a -> b) -> b ->Maybe a -> bSource# foldr1 :: (a -> a -> a) ->Maybe a -> aSource# foldl1 :: (a -> a -> a) ->Maybe a -> aSource# toList ::Maybe a -> [a]Source# elem ::Eq a => a ->Maybe a ->BoolSource# maximum ::Ord a =>Maybe a -> aSource# minimum ::Ord a =>Maybe a -> aSource# | |
| FoldablePar1Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Par1 m -> mSource# foldMap ::Monoid m => (a -> m) ->Par1 a -> mSource# foldr :: (a -> b -> b) -> b ->Par1 a -> bSource# foldr' :: (a -> b -> b) -> b ->Par1 a -> bSource# foldl :: (b -> a -> b) -> b ->Par1 a -> bSource# foldl' :: (b -> a -> b) -> b ->Par1 a -> bSource# foldr1 :: (a -> a -> a) ->Par1 a -> aSource# foldl1 :: (a -> a -> a) ->Par1 a -> aSource# elem ::Eq a => a ->Par1 a ->BoolSource# maximum ::Ord a =>Par1 a -> aSource# minimum ::Ord a =>Par1 a -> aSource# | |
| FoldableNonEmptySource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>NonEmpty m -> mSource# foldMap ::Monoid m => (a -> m) ->NonEmpty a -> mSource# foldr :: (a -> b -> b) -> b ->NonEmpty a -> bSource# foldr' :: (a -> b -> b) -> b ->NonEmpty a -> bSource# foldl :: (b -> a -> b) -> b ->NonEmpty a -> bSource# foldl' :: (b -> a -> b) -> b ->NonEmpty a -> bSource# foldr1 :: (a -> a -> a) ->NonEmpty a -> aSource# foldl1 :: (a -> a -> a) ->NonEmpty a -> aSource# toList ::NonEmpty a -> [a]Source# null ::NonEmpty a ->BoolSource# length ::NonEmpty a ->IntSource# elem ::Eq a => a ->NonEmpty a ->BoolSource# maximum ::Ord a =>NonEmpty a -> aSource# minimum ::Ord a =>NonEmpty a -> aSource# | |
| FoldableDownSource# | Since: 4.12.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Down m -> mSource# foldMap ::Monoid m => (a -> m) ->Down a -> mSource# foldr :: (a -> b -> b) -> b ->Down a -> bSource# foldr' :: (a -> b -> b) -> b ->Down a -> bSource# foldl :: (b -> a -> b) -> b ->Down a -> bSource# foldl' :: (b -> a -> b) -> b ->Down a -> bSource# foldr1 :: (a -> a -> a) ->Down a -> aSource# foldl1 :: (a -> a -> a) ->Down a -> aSource# elem ::Eq a => a ->Down a ->BoolSource# maximum ::Ord a =>Down a -> aSource# minimum ::Ord a =>Down a -> aSource# | |
| FoldableProductSource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Product m -> mSource# foldMap ::Monoid m => (a -> m) ->Product a -> mSource# foldr :: (a -> b -> b) -> b ->Product a -> bSource# foldr' :: (a -> b -> b) -> b ->Product a -> bSource# foldl :: (b -> a -> b) -> b ->Product a -> bSource# foldl' :: (b -> a -> b) -> b ->Product a -> bSource# foldr1 :: (a -> a -> a) ->Product a -> aSource# foldl1 :: (a -> a -> a) ->Product a -> aSource# toList ::Product a -> [a]Source# null ::Product a ->BoolSource# length ::Product a ->IntSource# elem ::Eq a => a ->Product a ->BoolSource# maximum ::Ord a =>Product a -> aSource# minimum ::Ord a =>Product a -> aSource# | |
| FoldableSumSource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Sum m -> mSource# foldMap ::Monoid m => (a -> m) ->Sum a -> mSource# foldr :: (a -> b -> b) -> b ->Sum a -> bSource# foldr' :: (a -> b -> b) -> b ->Sum a -> bSource# foldl :: (b -> a -> b) -> b ->Sum a -> bSource# foldl' :: (b -> a -> b) -> b ->Sum a -> bSource# foldr1 :: (a -> a -> a) ->Sum a -> aSource# foldl1 :: (a -> a -> a) ->Sum a -> aSource# elem ::Eq a => a ->Sum a ->BoolSource# maximum ::Ord a =>Sum a -> aSource# minimum ::Ord a =>Sum a -> aSource# | |
| FoldableDualSource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Dual m -> mSource# foldMap ::Monoid m => (a -> m) ->Dual a -> mSource# foldr :: (a -> b -> b) -> b ->Dual a -> bSource# foldr' :: (a -> b -> b) -> b ->Dual a -> bSource# foldl :: (b -> a -> b) -> b ->Dual a -> bSource# foldl' :: (b -> a -> b) -> b ->Dual a -> bSource# foldr1 :: (a -> a -> a) ->Dual a -> aSource# foldl1 :: (a -> a -> a) ->Dual a -> aSource# elem ::Eq a => a ->Dual a ->BoolSource# maximum ::Ord a =>Dual a -> aSource# minimum ::Ord a =>Dual a -> aSource# | |
| FoldableLastSource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Last m -> mSource# foldMap ::Monoid m => (a -> m) ->Last a -> mSource# foldr :: (a -> b -> b) -> b ->Last a -> bSource# foldr' :: (a -> b -> b) -> b ->Last a -> bSource# foldl :: (b -> a -> b) -> b ->Last a -> bSource# foldl' :: (b -> a -> b) -> b ->Last a -> bSource# foldr1 :: (a -> a -> a) ->Last a -> aSource# foldl1 :: (a -> a -> a) ->Last a -> aSource# elem ::Eq a => a ->Last a ->BoolSource# maximum ::Ord a =>Last a -> aSource# minimum ::Ord a =>Last a -> aSource# | |
| FoldableFirstSource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>First m -> mSource# foldMap ::Monoid m => (a -> m) ->First a -> mSource# foldr :: (a -> b -> b) -> b ->First a -> bSource# foldr' :: (a -> b -> b) -> b ->First a -> bSource# foldl :: (b -> a -> b) -> b ->First a -> bSource# foldl' :: (b -> a -> b) -> b ->First a -> bSource# foldr1 :: (a -> a -> a) ->First a -> aSource# foldl1 :: (a -> a -> a) ->First a -> aSource# toList ::First a -> [a]Source# elem ::Eq a => a ->First a ->BoolSource# maximum ::Ord a =>First a -> aSource# minimum ::Ord a =>First a -> aSource# | |
| FoldableIdentitySource# | Since: 4.8.0.0 |
Instance detailsDefined inData.Functor.Identity Methods fold ::Monoid m =>Identity m -> mSource# foldMap ::Monoid m => (a -> m) ->Identity a -> mSource# foldr :: (a -> b -> b) -> b ->Identity a -> bSource# foldr' :: (a -> b -> b) -> b ->Identity a -> bSource# foldl :: (b -> a -> b) -> b ->Identity a -> bSource# foldl' :: (b -> a -> b) -> b ->Identity a -> bSource# foldr1 :: (a -> a -> a) ->Identity a -> aSource# foldl1 :: (a -> a -> a) ->Identity a -> aSource# toList ::Identity a -> [a]Source# null ::Identity a ->BoolSource# length ::Identity a ->IntSource# elem ::Eq a => a ->Identity a ->BoolSource# maximum ::Ord a =>Identity a -> aSource# minimum ::Ord a =>Identity a -> aSource# | |
| FoldableZipListSource# | Since: 4.9.0.0 |
Instance detailsDefined inControl.Applicative Methods fold ::Monoid m =>ZipList m -> mSource# foldMap ::Monoid m => (a -> m) ->ZipList a -> mSource# foldr :: (a -> b -> b) -> b ->ZipList a -> bSource# foldr' :: (a -> b -> b) -> b ->ZipList a -> bSource# foldl :: (b -> a -> b) -> b ->ZipList a -> bSource# foldl' :: (b -> a -> b) -> b ->ZipList a -> bSource# foldr1 :: (a -> a -> a) ->ZipList a -> aSource# foldl1 :: (a -> a -> a) ->ZipList a -> aSource# toList ::ZipList a -> [a]Source# null ::ZipList a ->BoolSource# length ::ZipList a ->IntSource# elem ::Eq a => a ->ZipList a ->BoolSource# maximum ::Ord a =>ZipList a -> aSource# minimum ::Ord a =>ZipList a -> aSource# | |
| FoldableOptionSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>Option m -> mSource# foldMap ::Monoid m => (a -> m) ->Option a -> mSource# foldr :: (a -> b -> b) -> b ->Option a -> bSource# foldr' :: (a -> b -> b) -> b ->Option a -> bSource# foldl :: (b -> a -> b) -> b ->Option a -> bSource# foldl' :: (b -> a -> b) -> b ->Option a -> bSource# foldr1 :: (a -> a -> a) ->Option a -> aSource# foldl1 :: (a -> a -> a) ->Option a -> aSource# toList ::Option a -> [a]Source# length ::Option a ->IntSource# elem ::Eq a => a ->Option a ->BoolSource# maximum ::Ord a =>Option a -> aSource# minimum ::Ord a =>Option a -> aSource# | |
| FoldableLastSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>Last m -> mSource# foldMap ::Monoid m => (a -> m) ->Last a -> mSource# foldr :: (a -> b -> b) -> b ->Last a -> bSource# foldr' :: (a -> b -> b) -> b ->Last a -> bSource# foldl :: (b -> a -> b) -> b ->Last a -> bSource# foldl' :: (b -> a -> b) -> b ->Last a -> bSource# foldr1 :: (a -> a -> a) ->Last a -> aSource# foldl1 :: (a -> a -> a) ->Last a -> aSource# elem ::Eq a => a ->Last a ->BoolSource# maximum ::Ord a =>Last a -> aSource# minimum ::Ord a =>Last a -> aSource# | |
| FoldableFirstSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>First m -> mSource# foldMap ::Monoid m => (a -> m) ->First a -> mSource# foldr :: (a -> b -> b) -> b ->First a -> bSource# foldr' :: (a -> b -> b) -> b ->First a -> bSource# foldl :: (b -> a -> b) -> b ->First a -> bSource# foldl' :: (b -> a -> b) -> b ->First a -> bSource# foldr1 :: (a -> a -> a) ->First a -> aSource# foldl1 :: (a -> a -> a) ->First a -> aSource# toList ::First a -> [a]Source# elem ::Eq a => a ->First a ->BoolSource# maximum ::Ord a =>First a -> aSource# minimum ::Ord a =>First a -> aSource# | |
| FoldableMaxSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>Max m -> mSource# foldMap ::Monoid m => (a -> m) ->Max a -> mSource# foldr :: (a -> b -> b) -> b ->Max a -> bSource# foldr' :: (a -> b -> b) -> b ->Max a -> bSource# foldl :: (b -> a -> b) -> b ->Max a -> bSource# foldl' :: (b -> a -> b) -> b ->Max a -> bSource# foldr1 :: (a -> a -> a) ->Max a -> aSource# foldl1 :: (a -> a -> a) ->Max a -> aSource# elem ::Eq a => a ->Max a ->BoolSource# maximum ::Ord a =>Max a -> aSource# minimum ::Ord a =>Max a -> aSource# | |
| FoldableMinSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>Min m -> mSource# foldMap ::Monoid m => (a -> m) ->Min a -> mSource# foldr :: (a -> b -> b) -> b ->Min a -> bSource# foldr' :: (a -> b -> b) -> b ->Min a -> bSource# foldl :: (b -> a -> b) -> b ->Min a -> bSource# foldl' :: (b -> a -> b) -> b ->Min a -> bSource# foldr1 :: (a -> a -> a) ->Min a -> aSource# foldl1 :: (a -> a -> a) ->Min a -> aSource# elem ::Eq a => a ->Min a ->BoolSource# maximum ::Ord a =>Min a -> aSource# minimum ::Ord a =>Min a -> aSource# | |
| FoldableComplexSource# | Since: 4.9.0.0 |
Instance detailsDefined inData.Complex Methods fold ::Monoid m =>Complex m -> mSource# foldMap ::Monoid m => (a -> m) ->Complex a -> mSource# foldr :: (a -> b -> b) -> b ->Complex a -> bSource# foldr' :: (a -> b -> b) -> b ->Complex a -> bSource# foldl :: (b -> a -> b) -> b ->Complex a -> bSource# foldl' :: (b -> a -> b) -> b ->Complex a -> bSource# foldr1 :: (a -> a -> a) ->Complex a -> aSource# foldl1 :: (a -> a -> a) ->Complex a -> aSource# toList ::Complex a -> [a]Source# null ::Complex a ->BoolSource# length ::Complex a ->IntSource# elem ::Eq a => a ->Complex a ->BoolSource# maximum ::Ord a =>Complex a -> aSource# minimum ::Ord a =>Complex a -> aSource# | |
| Foldable (Either a)Source# | Since: 4.7.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Either a m -> mSource# foldMap ::Monoid m => (a0 -> m) ->Either a a0 -> mSource# foldr :: (a0 -> b -> b) -> b ->Either a a0 -> bSource# foldr' :: (a0 -> b -> b) -> b ->Either a a0 -> bSource# foldl :: (b -> a0 -> b) -> b ->Either a a0 -> bSource# foldl' :: (b -> a0 -> b) -> b ->Either a a0 -> bSource# foldr1 :: (a0 -> a0 -> a0) ->Either a a0 -> a0Source# foldl1 :: (a0 -> a0 -> a0) ->Either a a0 -> a0Source# toList ::Either a a0 -> [a0]Source# null ::Either a a0 ->BoolSource# length ::Either a a0 ->IntSource# elem ::Eq a0 => a0 ->Either a a0 ->BoolSource# maximum ::Ord a0 =>Either a a0 -> a0Source# minimum ::Ord a0 =>Either a a0 -> a0Source# | |
| Foldable (V1 ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>V1 m -> mSource# foldMap ::Monoid m => (a -> m) ->V1 a -> mSource# foldr :: (a -> b -> b) -> b ->V1 a -> bSource# foldr' :: (a -> b -> b) -> b ->V1 a -> bSource# foldl :: (b -> a -> b) -> b ->V1 a -> bSource# foldl' :: (b -> a -> b) -> b ->V1 a -> bSource# foldr1 :: (a -> a -> a) ->V1 a -> aSource# foldl1 :: (a -> a -> a) ->V1 a -> aSource# elem ::Eq a => a ->V1 a ->BoolSource# maximum ::Ord a =>V1 a -> aSource# minimum ::Ord a =>V1 a -> aSource# | |
| Foldable (U1 ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>U1 m -> mSource# foldMap ::Monoid m => (a -> m) ->U1 a -> mSource# foldr :: (a -> b -> b) -> b ->U1 a -> bSource# foldr' :: (a -> b -> b) -> b ->U1 a -> bSource# foldl :: (b -> a -> b) -> b ->U1 a -> bSource# foldl' :: (b -> a -> b) -> b ->U1 a -> bSource# foldr1 :: (a -> a -> a) ->U1 a -> aSource# foldl1 :: (a -> a -> a) ->U1 a -> aSource# elem ::Eq a => a ->U1 a ->BoolSource# maximum ::Ord a =>U1 a -> aSource# minimum ::Ord a =>U1 a -> aSource# | |
| Foldable ((,) a)Source# | Since: 4.7.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m => (a, m) -> mSource# foldMap ::Monoid m => (a0 -> m) -> (a, a0) -> mSource# foldr :: (a0 -> b -> b) -> b -> (a, a0) -> bSource# foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> bSource# foldl :: (b -> a0 -> b) -> b -> (a, a0) -> bSource# foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> bSource# foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0Source# foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0Source# toList :: (a, a0) -> [a0]Source# length :: (a, a0) ->IntSource# elem ::Eq a0 => a0 -> (a, a0) ->BoolSource# maximum ::Ord a0 => (a, a0) -> a0Source# minimum ::Ord a0 => (a, a0) -> a0Source# | |
| Foldable (Proxy ::Type ->Type)Source# | Since: 4.7.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Proxy m -> mSource# foldMap ::Monoid m => (a -> m) ->Proxy a -> mSource# foldr :: (a -> b -> b) -> b ->Proxy a -> bSource# foldr' :: (a -> b -> b) -> b ->Proxy a -> bSource# foldl :: (b -> a -> b) -> b ->Proxy a -> bSource# foldl' :: (b -> a -> b) -> b ->Proxy a -> bSource# foldr1 :: (a -> a -> a) ->Proxy a -> aSource# foldl1 :: (a -> a -> a) ->Proxy a -> aSource# toList ::Proxy a -> [a]Source# elem ::Eq a => a ->Proxy a ->BoolSource# maximum ::Ord a =>Proxy a -> aSource# minimum ::Ord a =>Proxy a -> aSource# | |
| Foldable (Arg a)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Semigroup Methods fold ::Monoid m =>Arg a m -> mSource# foldMap ::Monoid m => (a0 -> m) ->Arg a a0 -> mSource# foldr :: (a0 -> b -> b) -> b ->Arg a a0 -> bSource# foldr' :: (a0 -> b -> b) -> b ->Arg a a0 -> bSource# foldl :: (b -> a0 -> b) -> b ->Arg a a0 -> bSource# foldl' :: (b -> a0 -> b) -> b ->Arg a a0 -> bSource# foldr1 :: (a0 -> a0 -> a0) ->Arg a a0 -> a0Source# foldl1 :: (a0 -> a0 -> a0) ->Arg a a0 -> a0Source# toList ::Arg a a0 -> [a0]Source# length ::Arg a a0 ->IntSource# elem ::Eq a0 => a0 ->Arg a a0 ->BoolSource# maximum ::Ord a0 =>Arg a a0 -> a0Source# minimum ::Ord a0 =>Arg a a0 -> a0Source# | |
| Foldable f =>Foldable (Rec1 f)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Rec1 f m -> mSource# foldMap ::Monoid m => (a -> m) ->Rec1 f a -> mSource# foldr :: (a -> b -> b) -> b ->Rec1 f a -> bSource# foldr' :: (a -> b -> b) -> b ->Rec1 f a -> bSource# foldl :: (b -> a -> b) -> b ->Rec1 f a -> bSource# foldl' :: (b -> a -> b) -> b ->Rec1 f a -> bSource# foldr1 :: (a -> a -> a) ->Rec1 f a -> aSource# foldl1 :: (a -> a -> a) ->Rec1 f a -> aSource# toList ::Rec1 f a -> [a]Source# length ::Rec1 f a ->IntSource# elem ::Eq a => a ->Rec1 f a ->BoolSource# maximum ::Ord a =>Rec1 f a -> aSource# minimum ::Ord a =>Rec1 f a -> aSource# | |
| Foldable (URecChar ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URecChar m -> mSource# foldMap ::Monoid m => (a -> m) ->URecChar a -> mSource# foldr :: (a -> b -> b) -> b ->URecChar a -> bSource# foldr' :: (a -> b -> b) -> b ->URecChar a -> bSource# foldl :: (b -> a -> b) -> b ->URecChar a -> bSource# foldl' :: (b -> a -> b) -> b ->URecChar a -> bSource# foldr1 :: (a -> a -> a) ->URecChar a -> aSource# foldl1 :: (a -> a -> a) ->URecChar a -> aSource# toList ::URecChar a -> [a]Source# null ::URecChar a ->BoolSource# length ::URecChar a ->IntSource# elem ::Eq a => a ->URecChar a ->BoolSource# maximum ::Ord a =>URecChar a -> aSource# minimum ::Ord a =>URecChar a -> aSource# | |
| Foldable (URecDouble ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URecDouble m -> mSource# foldMap ::Monoid m => (a -> m) ->URecDouble a -> mSource# foldr :: (a -> b -> b) -> b ->URecDouble a -> bSource# foldr' :: (a -> b -> b) -> b ->URecDouble a -> bSource# foldl :: (b -> a -> b) -> b ->URecDouble a -> bSource# foldl' :: (b -> a -> b) -> b ->URecDouble a -> bSource# foldr1 :: (a -> a -> a) ->URecDouble a -> aSource# foldl1 :: (a -> a -> a) ->URecDouble a -> aSource# toList ::URecDouble a -> [a]Source# null ::URecDouble a ->BoolSource# length ::URecDouble a ->IntSource# elem ::Eq a => a ->URecDouble a ->BoolSource# maximum ::Ord a =>URecDouble a -> aSource# minimum ::Ord a =>URecDouble a -> aSource# | |
| Foldable (URecFloat ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URecFloat m -> mSource# foldMap ::Monoid m => (a -> m) ->URecFloat a -> mSource# foldr :: (a -> b -> b) -> b ->URecFloat a -> bSource# foldr' :: (a -> b -> b) -> b ->URecFloat a -> bSource# foldl :: (b -> a -> b) -> b ->URecFloat a -> bSource# foldl' :: (b -> a -> b) -> b ->URecFloat a -> bSource# foldr1 :: (a -> a -> a) ->URecFloat a -> aSource# foldl1 :: (a -> a -> a) ->URecFloat a -> aSource# toList ::URecFloat a -> [a]Source# null ::URecFloat a ->BoolSource# length ::URecFloat a ->IntSource# elem ::Eq a => a ->URecFloat a ->BoolSource# maximum ::Ord a =>URecFloat a -> aSource# minimum ::Ord a =>URecFloat a -> aSource# | |
| Foldable (URecInt ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URecInt m -> mSource# foldMap ::Monoid m => (a -> m) ->URecInt a -> mSource# foldr :: (a -> b -> b) -> b ->URecInt a -> bSource# foldr' :: (a -> b -> b) -> b ->URecInt a -> bSource# foldl :: (b -> a -> b) -> b ->URecInt a -> bSource# foldl' :: (b -> a -> b) -> b ->URecInt a -> bSource# foldr1 :: (a -> a -> a) ->URecInt a -> aSource# foldl1 :: (a -> a -> a) ->URecInt a -> aSource# toList ::URecInt a -> [a]Source# null ::URecInt a ->BoolSource# length ::URecInt a ->IntSource# elem ::Eq a => a ->URecInt a ->BoolSource# maximum ::Ord a =>URecInt a -> aSource# minimum ::Ord a =>URecInt a -> aSource# | |
| Foldable (URecWord ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URecWord m -> mSource# foldMap ::Monoid m => (a -> m) ->URecWord a -> mSource# foldr :: (a -> b -> b) -> b ->URecWord a -> bSource# foldr' :: (a -> b -> b) -> b ->URecWord a -> bSource# foldl :: (b -> a -> b) -> b ->URecWord a -> bSource# foldl' :: (b -> a -> b) -> b ->URecWord a -> bSource# foldr1 :: (a -> a -> a) ->URecWord a -> aSource# foldl1 :: (a -> a -> a) ->URecWord a -> aSource# toList ::URecWord a -> [a]Source# null ::URecWord a ->BoolSource# length ::URecWord a ->IntSource# elem ::Eq a => a ->URecWord a ->BoolSource# maximum ::Ord a =>URecWord a -> aSource# minimum ::Ord a =>URecWord a -> aSource# | |
| Foldable (URec (Ptr ()) ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>URec (Ptr ()) m -> mSource# foldMap ::Monoid m => (a -> m) ->URec (Ptr ()) a -> mSource# foldr :: (a -> b -> b) -> b ->URec (Ptr ()) a -> bSource# foldr' :: (a -> b -> b) -> b ->URec (Ptr ()) a -> bSource# foldl :: (b -> a -> b) -> b ->URec (Ptr ()) a -> bSource# foldl' :: (b -> a -> b) -> b ->URec (Ptr ()) a -> bSource# foldr1 :: (a -> a -> a) ->URec (Ptr ()) a -> aSource# foldl1 :: (a -> a -> a) ->URec (Ptr ()) a -> aSource# toList ::URec (Ptr ()) a -> [a]Source# null ::URec (Ptr ()) a ->BoolSource# length ::URec (Ptr ()) a ->IntSource# elem ::Eq a => a ->URec (Ptr ()) a ->BoolSource# maximum ::Ord a =>URec (Ptr ()) a -> aSource# minimum ::Ord a =>URec (Ptr ()) a -> aSource# | |
| Foldable f =>Foldable (Alt f)Source# | Since: 4.12.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Alt f m -> mSource# foldMap ::Monoid m => (a -> m) ->Alt f a -> mSource# foldr :: (a -> b -> b) -> b ->Alt f a -> bSource# foldr' :: (a -> b -> b) -> b ->Alt f a -> bSource# foldl :: (b -> a -> b) -> b ->Alt f a -> bSource# foldl' :: (b -> a -> b) -> b ->Alt f a -> bSource# foldr1 :: (a -> a -> a) ->Alt f a -> aSource# foldl1 :: (a -> a -> a) ->Alt f a -> aSource# toList ::Alt f a -> [a]Source# elem ::Eq a => a ->Alt f a ->BoolSource# maximum ::Ord a =>Alt f a -> aSource# minimum ::Ord a =>Alt f a -> aSource# | |
| Foldable f =>Foldable (Ap f)Source# | Since: 4.12.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>Ap f m -> mSource# foldMap ::Monoid m => (a -> m) ->Ap f a -> mSource# foldr :: (a -> b -> b) -> b ->Ap f a -> bSource# foldr' :: (a -> b -> b) -> b ->Ap f a -> bSource# foldl :: (b -> a -> b) -> b ->Ap f a -> bSource# foldl' :: (b -> a -> b) -> b ->Ap f a -> bSource# foldr1 :: (a -> a -> a) ->Ap f a -> aSource# foldl1 :: (a -> a -> a) ->Ap f a -> aSource# elem ::Eq a => a ->Ap f a ->BoolSource# maximum ::Ord a =>Ap f a -> aSource# minimum ::Ord a =>Ap f a -> aSource# | |
| Foldable (Const m ::Type ->Type)Source# | Since: 4.7.0.0 |
Instance detailsDefined inData.Functor.Const Methods fold ::Monoid m0 =>Const m m0 -> m0Source# foldMap ::Monoid m0 => (a -> m0) ->Const m a -> m0Source# foldr :: (a -> b -> b) -> b ->Const m a -> bSource# foldr' :: (a -> b -> b) -> b ->Const m a -> bSource# foldl :: (b -> a -> b) -> b ->Const m a -> bSource# foldl' :: (b -> a -> b) -> b ->Const m a -> bSource# foldr1 :: (a -> a -> a) ->Const m a -> aSource# foldl1 :: (a -> a -> a) ->Const m a -> aSource# toList ::Const m a -> [a]Source# null ::Const m a ->BoolSource# length ::Const m a ->IntSource# elem ::Eq a => a ->Const m a ->BoolSource# maximum ::Ord a =>Const m a -> aSource# minimum ::Ord a =>Const m a -> aSource# | |
| Foldable (K1 i c ::Type ->Type)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>K1 i c m -> mSource# foldMap ::Monoid m => (a -> m) ->K1 i c a -> mSource# foldr :: (a -> b -> b) -> b ->K1 i c a -> bSource# foldr' :: (a -> b -> b) -> b ->K1 i c a -> bSource# foldl :: (b -> a -> b) -> b ->K1 i c a -> bSource# foldl' :: (b -> a -> b) -> b ->K1 i c a -> bSource# foldr1 :: (a -> a -> a) ->K1 i c a -> aSource# foldl1 :: (a -> a -> a) ->K1 i c a -> aSource# toList ::K1 i c a -> [a]Source# length ::K1 i c a ->IntSource# elem ::Eq a => a ->K1 i c a ->BoolSource# maximum ::Ord a =>K1 i c a -> aSource# minimum ::Ord a =>K1 i c a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (f:+: g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m => (f:+: g) m -> mSource# foldMap ::Monoid m => (a -> m) -> (f:+: g) a -> mSource# foldr :: (a -> b -> b) -> b -> (f:+: g) a -> bSource# foldr' :: (a -> b -> b) -> b -> (f:+: g) a -> bSource# foldl :: (b -> a -> b) -> b -> (f:+: g) a -> bSource# foldl' :: (b -> a -> b) -> b -> (f:+: g) a -> bSource# foldr1 :: (a -> a -> a) -> (f:+: g) a -> aSource# foldl1 :: (a -> a -> a) -> (f:+: g) a -> aSource# toList :: (f:+: g) a -> [a]Source# null :: (f:+: g) a ->BoolSource# length :: (f:+: g) a ->IntSource# elem ::Eq a => a -> (f:+: g) a ->BoolSource# maximum ::Ord a => (f:+: g) a -> aSource# minimum ::Ord a => (f:+: g) a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (f:*: g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m => (f:*: g) m -> mSource# foldMap ::Monoid m => (a -> m) -> (f:*: g) a -> mSource# foldr :: (a -> b -> b) -> b -> (f:*: g) a -> bSource# foldr' :: (a -> b -> b) -> b -> (f:*: g) a -> bSource# foldl :: (b -> a -> b) -> b -> (f:*: g) a -> bSource# foldl' :: (b -> a -> b) -> b -> (f:*: g) a -> bSource# foldr1 :: (a -> a -> a) -> (f:*: g) a -> aSource# foldl1 :: (a -> a -> a) -> (f:*: g) a -> aSource# toList :: (f:*: g) a -> [a]Source# null :: (f:*: g) a ->BoolSource# length :: (f:*: g) a ->IntSource# elem ::Eq a => a -> (f:*: g) a ->BoolSource# maximum ::Ord a => (f:*: g) a -> aSource# minimum ::Ord a => (f:*: g) a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (Sum f g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Functor.Sum Methods fold ::Monoid m =>Sum f g m -> mSource# foldMap ::Monoid m => (a -> m) ->Sum f g a -> mSource# foldr :: (a -> b -> b) -> b ->Sum f g a -> bSource# foldr' :: (a -> b -> b) -> b ->Sum f g a -> bSource# foldl :: (b -> a -> b) -> b ->Sum f g a -> bSource# foldl' :: (b -> a -> b) -> b ->Sum f g a -> bSource# foldr1 :: (a -> a -> a) ->Sum f g a -> aSource# foldl1 :: (a -> a -> a) ->Sum f g a -> aSource# toList ::Sum f g a -> [a]Source# null ::Sum f g a ->BoolSource# length ::Sum f g a ->IntSource# elem ::Eq a => a ->Sum f g a ->BoolSource# maximum ::Ord a =>Sum f g a -> aSource# minimum ::Ord a =>Sum f g a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (Product f g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Functor.Product Methods fold ::Monoid m =>Product f g m -> mSource# foldMap ::Monoid m => (a -> m) ->Product f g a -> mSource# foldr :: (a -> b -> b) -> b ->Product f g a -> bSource# foldr' :: (a -> b -> b) -> b ->Product f g a -> bSource# foldl :: (b -> a -> b) -> b ->Product f g a -> bSource# foldl' :: (b -> a -> b) -> b ->Product f g a -> bSource# foldr1 :: (a -> a -> a) ->Product f g a -> aSource# foldl1 :: (a -> a -> a) ->Product f g a -> aSource# toList ::Product f g a -> [a]Source# null ::Product f g a ->BoolSource# length ::Product f g a ->IntSource# elem ::Eq a => a ->Product f g a ->BoolSource# maximum ::Ord a =>Product f g a -> aSource# minimum ::Ord a =>Product f g a -> aSource# | |
| Foldable f =>Foldable (M1 i c f)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m =>M1 i c f m -> mSource# foldMap ::Monoid m => (a -> m) ->M1 i c f a -> mSource# foldr :: (a -> b -> b) -> b ->M1 i c f a -> bSource# foldr' :: (a -> b -> b) -> b ->M1 i c f a -> bSource# foldl :: (b -> a -> b) -> b ->M1 i c f a -> bSource# foldl' :: (b -> a -> b) -> b ->M1 i c f a -> bSource# foldr1 :: (a -> a -> a) ->M1 i c f a -> aSource# foldl1 :: (a -> a -> a) ->M1 i c f a -> aSource# toList ::M1 i c f a -> [a]Source# null ::M1 i c f a ->BoolSource# length ::M1 i c f a ->IntSource# elem ::Eq a => a ->M1 i c f a ->BoolSource# maximum ::Ord a =>M1 i c f a -> aSource# minimum ::Ord a =>M1 i c f a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (f:.: g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Foldable Methods fold ::Monoid m => (f:.: g) m -> mSource# foldMap ::Monoid m => (a -> m) -> (f:.: g) a -> mSource# foldr :: (a -> b -> b) -> b -> (f:.: g) a -> bSource# foldr' :: (a -> b -> b) -> b -> (f:.: g) a -> bSource# foldl :: (b -> a -> b) -> b -> (f:.: g) a -> bSource# foldl' :: (b -> a -> b) -> b -> (f:.: g) a -> bSource# foldr1 :: (a -> a -> a) -> (f:.: g) a -> aSource# foldl1 :: (a -> a -> a) -> (f:.: g) a -> aSource# toList :: (f:.: g) a -> [a]Source# null :: (f:.: g) a ->BoolSource# length :: (f:.: g) a ->IntSource# elem ::Eq a => a -> (f:.: g) a ->BoolSource# maximum ::Ord a => (f:.: g) a -> aSource# minimum ::Ord a => (f:.: g) a -> aSource# | |
| (Foldable f,Foldable g) =>Foldable (Compose f g)Source# | Since: 4.9.0.0 |
Instance detailsDefined inData.Functor.Compose Methods fold ::Monoid m =>Compose f g m -> mSource# foldMap ::Monoid m => (a -> m) ->Compose f g a -> mSource# foldr :: (a -> b -> b) -> b ->Compose f g a -> bSource# foldr' :: (a -> b -> b) -> b ->Compose f g a -> bSource# foldl :: (b -> a -> b) -> b ->Compose f g a -> bSource# foldl' :: (b -> a -> b) -> b ->Compose f g a -> bSource# foldr1 :: (a -> a -> a) ->Compose f g a -> aSource# foldl1 :: (a -> a -> a) ->Compose f g a -> aSource# toList ::Compose f g a -> [a]Source# null ::Compose f g a ->BoolSource# length ::Compose f g a ->IntSource# elem ::Eq a => a ->Compose f g a ->BoolSource# maximum ::Ord a =>Compose f g a -> aSource# minimum ::Ord a =>Compose f g a -> aSource# | |
foldrM :: (Foldable t,Monad m) => (a -> b -> m b) -> b -> t a -> m bSource#
Monadic fold over the elements of a structure, associating to the right, i.e. from right to left.
foldlM :: (Foldable t,Monad m) => (b -> a -> m b) -> b -> t a -> m bSource#
Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.
traverse_ :: (Foldable t,Applicative f) => (a -> f b) -> t a -> f ()Source#
Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results seetraverse.
for_ :: (Foldable t,Applicative f) => t a -> (a -> f b) -> f ()Source#
sequenceA_ :: (Foldable t,Applicative f) => t (f a) -> f ()Source#
Evaluate each action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results seesequenceA.
asum :: (Foldable t,Alternative f) => t (f a) -> f aSource#
sequence_ :: (Foldable t,Monad m) => t (m a) -> m ()Source#
Evaluate each monadic action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results seesequence.
As of base 4.8.0.0,sequence_ is justsequenceA_, specialized toMonad.
concat ::Foldable t => t [a] -> [a]Source#
The concatenation of all the elements of a container of lists.
concatMap ::Foldable t => (a -> [b]) -> t a -> [b]Source#
Map a function over all the elements of a container and concatenate the resulting lists.
any ::Foldable t => (a ->Bool) -> t a ->BoolSource#
Determines whether any element of the structure satisfies the predicate.
all ::Foldable t => (a ->Bool) -> t a ->BoolSource#
Determines whether all elements of the structure satisfy the predicate.
maximumBy ::Foldable t => (a -> a ->Ordering) -> t a -> aSource#
The largest element of a non-empty structure with respect to the given comparison function.
minimumBy ::Foldable t => (a -> a ->Ordering) -> t a -> aSource#
The least element of a non-empty structure with respect to the given comparison function.
Produced byHaddock version 2.20.0