Data.Foldable

Copyright Ross Paterson 2005
License BSD-style (see the LICENSE file in the distribution)
Maintainer [email protected]
Stability experimental
Portability portable
Safe Haskell Trustworthy
Language Haskell2010

Description

Class of data structures that can be folded to a summary value.

class Foldable t where Source

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 define foldr:

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, and minimum should all be essentially equivalent to foldMap forms, such as

sum = getSum . foldMap Sum

but may be less defined.

If the type is also a Functor instance, it should satisfy

foldMap f = fold . fmap f

which implies that

foldMap f . fmap g = foldMap (f . g)

Minimal complete definition

foldMap | foldr

Methods

fold :: Monoid m => t m -> m Source

Combine the elements of a structure using a monoid.

foldMap :: Monoid m => (a -> m) -> t a -> m Source

Map each element of the structure to a monoid, and combine the results.

foldMap' :: Monoid m => (a -> m) -> t a -> m Source

A variant of foldMap that is strict in the accumulator.

Since: base-4.13.0.0

foldr :: (a -> b -> b) -> b -> t a -> b Source

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 general Foldable structure this should be semantically identical to,

foldr f z = foldr f z . toList

foldr' :: (a -> b -> b) -> b -> t a -> b Source

Right-associative fold of a structure, but with strict application of the operator.

Since: base-4.6.0.0

foldl :: (b -> a -> b) -> b -> t a -> b Source

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 that foldl' will diverge if given an infinite list.

Also note that if you want an efficient left-fold, you probably want to use foldl' instead of foldl. The reason for this is that latter does not force the "inner" results (e.g. z `f` x1 in the above example) before applying them to the operator (e.g. to (`f` x2)). This results in a thunk chain \(\mathcal{O}(n)\) elements long, which then must be evaluated from the outside-in.

For a general Foldable structure this should be semantically identical to,

foldl f z = foldl f z . toList

foldl' :: (b -> a -> b) -> b -> t a -> b Source

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 general Foldable structure this should be semantically identical to,

foldl' f z = foldl' f z . toList

Since: base-4.6.0.0

foldr1 :: (a -> a -> a) -> t a -> a Source

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

foldr1 f = foldr1 f . toList

foldl1 :: (a -> a -> a) -> t a -> a Source

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

foldl1 f = foldl1 f . toList

toList :: t a -> [a] Source

List of elements of a structure, from left to right.

Since: base-4.8.0.0

null :: t a -> Bool Source

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.

Since: base-4.8.0.0

length :: t a -> Int Source

Returns the size/length of a finite structure as an Int. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

Since: base-4.8.0.0

elem :: Eq a => a -> t a -> Bool infix 4 Source

Does the element occur in the structure?

Since: base-4.8.0.0

maximum :: forall a. Ord a => t a -> a Source

The largest element of a non-empty structure.

Since: base-4.8.0.0

minimum :: forall a. Ord a => t a -> a Source

The least element of a non-empty structure.

Since: base-4.8.0.0

sum :: Num a => t a -> a Source

The sum function computes the sum of the numbers of a structure.

Since: base-4.8.0.0

product :: Num a => t a -> a Source

The product function computes the product of the numbers of a structure.

Since: base-4.8.0.0

Instances
Instances details
Foldable []

Since: base-2.1

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => [m] -> m Source

foldMap :: Monoid m => (a -> m) -> [a] -> m Source

foldMap' :: Monoid m => (a -> m) -> [a] -> m Source

foldr :: (a -> b -> b) -> b -> [a] -> b Source

foldr' :: (a -> b -> b) -> b -> [a] -> b Source

foldl :: (b -> a -> b) -> b -> [a] -> b Source

foldl' :: (b -> a -> b) -> b -> [a] -> b Source

foldr1 :: (a -> a -> a) -> [a] -> a Source

foldl1 :: (a -> a -> a) -> [a] -> a Source

toList :: [a] -> [a] Source

null :: [a] -> Bool Source

length :: [a] -> Int Source

elem :: Eq a => a -> [a] -> Bool Source

maximum :: Ord a => [a] -> a Source

minimum :: Ord a => [a] -> a Source

sum :: Num a => [a] -> a Source

product :: Num a => [a] -> a Source

Foldable Maybe

Since: base-2.1

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Maybe m -> m Source

foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source

foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source

foldr :: (a -> b -> b) -> b -> Maybe a -> b Source

foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source

foldl :: (b -> a -> b) -> b -> Maybe a -> b Source

foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source

foldr1 :: (a -> a -> a) -> Maybe a -> a Source

foldl1 :: (a -> a -> a) -> Maybe a -> a Source

toList :: Maybe a -> [a] Source

null :: Maybe a -> Bool Source

length :: Maybe a -> Int Source

elem :: Eq a => a -> Maybe a -> Bool Source

maximum :: Ord a => Maybe a -> a Source

minimum :: Ord a => Maybe a -> a Source

sum :: Num a => Maybe a -> a Source

product :: Num a => Maybe a -> a Source

Foldable Par1

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Par1 m -> m Source

foldMap :: Monoid m => (a -> m) -> Par1 a -> m Source

foldMap' :: Monoid m => (a -> m) -> Par1 a -> m Source

foldr :: (a -> b -> b) -> b -> Par1 a -> b Source

foldr' :: (a -> b -> b) -> b -> Par1 a -> b Source

foldl :: (b -> a -> b) -> b -> Par1 a -> b Source

foldl' :: (b -> a -> b) -> b -> Par1 a -> b Source

foldr1 :: (a -> a -> a) -> Par1 a -> a Source

foldl1 :: (a -> a -> a) -> Par1 a -> a Source

toList :: Par1 a -> [a] Source

null :: Par1 a -> Bool Source

length :: Par1 a -> Int Source

elem :: Eq a => a -> Par1 a -> Bool Source

maximum :: Ord a => Par1 a -> a Source

minimum :: Ord a => Par1 a -> a Source

sum :: Num a => Par1 a -> a Source

product :: Num a => Par1 a -> a Source

Foldable NonEmpty

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => NonEmpty m -> m Source

foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m Source

foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m Source

foldr :: (a -> b -> b) -> b -> NonEmpty a -> b Source

foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b Source

foldl :: (b -> a -> b) -> b -> NonEmpty a -> b Source

foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b Source

foldr1 :: (a -> a -> a) -> NonEmpty a -> a Source

foldl1 :: (a -> a -> a) -> NonEmpty a -> a Source

toList :: NonEmpty a -> [a] Source

null :: NonEmpty a -> Bool Source

length :: NonEmpty a -> Int Source

elem :: Eq a => a -> NonEmpty a -> Bool Source

maximum :: Ord a => NonEmpty a -> a Source

minimum :: Ord a => NonEmpty a -> a Source

sum :: Num a => NonEmpty a -> a Source

product :: Num a => NonEmpty a -> a Source

Foldable Down

Since: base-4.12.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Down m -> m Source

foldMap :: Monoid m => (a -> m) -> Down a -> m Source

foldMap' :: Monoid m => (a -> m) -> Down a -> m Source

foldr :: (a -> b -> b) -> b -> Down a -> b Source

foldr' :: (a -> b -> b) -> b -> Down a -> b Source

foldl :: (b -> a -> b) -> b -> Down a -> b Source

foldl' :: (b -> a -> b) -> b -> Down a -> b Source

foldr1 :: (a -> a -> a) -> Down a -> a Source

foldl1 :: (a -> a -> a) -> Down a -> a Source

toList :: Down a -> [a] Source

null :: Down a -> Bool Source

length :: Down a -> Int Source

elem :: Eq a => a -> Down a -> Bool Source

maximum :: Ord a => Down a -> a Source

minimum :: Ord a => Down a -> a Source

sum :: Num a => Down a -> a Source

product :: Num a => Down a -> a Source

Foldable Product

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Product m -> m Source

foldMap :: Monoid m => (a -> m) -> Product a -> m Source

foldMap' :: Monoid m => (a -> m) -> Product a -> m Source

foldr :: (a -> b -> b) -> b -> Product a -> b Source

foldr' :: (a -> b -> b) -> b -> Product a -> b Source

foldl :: (b -> a -> b) -> b -> Product a -> b Source

foldl' :: (b -> a -> b) -> b -> Product a -> b Source

foldr1 :: (a -> a -> a) -> Product a -> a Source

foldl1 :: (a -> a -> a) -> Product a -> a Source

toList :: Product a -> [a] Source

null :: Product a -> Bool Source

length :: Product a -> Int Source

elem :: Eq a => a -> Product a -> Bool Source

maximum :: Ord a => Product a -> a Source

minimum :: Ord a => Product a -> a Source

sum :: Num a => Product a -> a Source

product :: Num a => Product a -> a Source

Foldable Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Sum m -> m Source

foldMap :: Monoid m => (a -> m) -> Sum a -> m Source

foldMap' :: Monoid m => (a -> m) -> Sum a -> m Source

foldr :: (a -> b -> b) -> b -> Sum a -> b Source

foldr' :: (a -> b -> b) -> b -> Sum a -> b Source

foldl :: (b -> a -> b) -> b -> Sum a -> b Source

foldl' :: (b -> a -> b) -> b -> Sum a -> b Source

foldr1 :: (a -> a -> a) -> Sum a -> a Source

foldl1 :: (a -> a -> a) -> Sum a -> a Source

toList :: Sum a -> [a] Source

null :: Sum a -> Bool Source

length :: Sum a -> Int Source

elem :: Eq a => a -> Sum a -> Bool Source

maximum :: Ord a => Sum a -> a Source

minimum :: Ord a => Sum a -> a Source

sum :: Num a => Sum a -> a Source

product :: Num a => Sum a -> a Source

Foldable Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Dual m -> m Source

foldMap :: Monoid m => (a -> m) -> Dual a -> m Source

foldMap' :: Monoid m => (a -> m) -> Dual a -> m Source

foldr :: (a -> b -> b) -> b -> Dual a -> b Source

foldr' :: (a -> b -> b) -> b -> Dual a -> b Source

foldl :: (b -> a -> b) -> b -> Dual a -> b Source

foldl' :: (b -> a -> b) -> b -> Dual a -> b Source

foldr1 :: (a -> a -> a) -> Dual a -> a Source

foldl1 :: (a -> a -> a) -> Dual a -> a Source

toList :: Dual a -> [a] Source

null :: Dual a -> Bool Source

length :: Dual a -> Int Source

elem :: Eq a => a -> Dual a -> Bool Source

maximum :: Ord a => Dual a -> a Source

minimum :: Ord a => Dual a -> a Source

sum :: Num a => Dual a -> a Source

product :: Num a => Dual a -> a Source

Foldable Last

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Last m -> m Source

foldMap :: Monoid m => (a -> m) -> Last a -> m Source

foldMap' :: Monoid m => (a -> m) -> Last a -> m Source

foldr :: (a -> b -> b) -> b -> Last a -> b Source

foldr' :: (a -> b -> b) -> b -> Last a -> b Source

foldl :: (b -> a -> b) -> b -> Last a -> b Source

foldl' :: (b -> a -> b) -> b -> Last a -> b Source

foldr1 :: (a -> a -> a) -> Last a -> a Source

foldl1 :: (a -> a -> a) -> Last a -> a Source

toList :: Last a -> [a] Source

null :: Last a -> Bool Source

length :: Last a -> Int Source

elem :: Eq a => a -> Last a -> Bool Source

maximum :: Ord a => Last a -> a Source

minimum :: Ord a => Last a -> a Source

sum :: Num a => Last a -> a Source

product :: Num a => Last a -> a Source

Foldable First

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => First m -> m Source

foldMap :: Monoid m => (a -> m) -> First a -> m Source

foldMap' :: Monoid m => (a -> m) -> First a -> m Source

foldr :: (a -> b -> b) -> b -> First a -> b Source

foldr' :: (a -> b -> b) -> b -> First a -> b Source

foldl :: (b -> a -> b) -> b -> First a -> b Source

foldl' :: (b -> a -> b) -> b -> First a -> b Source

foldr1 :: (a -> a -> a) -> First a -> a Source

foldl1 :: (a -> a -> a) -> First a -> a Source

toList :: First a -> [a] Source

null :: First a -> Bool Source

length :: First a -> Int Source

elem :: Eq a => a -> First a -> Bool Source

maximum :: Ord a => First a -> a Source

minimum :: Ord a => First a -> a Source

sum :: Num a => First a -> a Source

product :: Num a => First a -> a Source

Foldable Identity

Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Identity

Methods

fold :: Monoid m => Identity m -> m Source

foldMap :: Monoid m => (a -> m) -> Identity a -> m Source

foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source

foldr :: (a -> b -> b) -> b -> Identity a -> b Source

foldr' :: (a -> b -> b) -> b -> Identity a -> b Source

foldl :: (b -> a -> b) -> b -> Identity a -> b Source

foldl' :: (b -> a -> b) -> b -> Identity a -> b Source

foldr1 :: (a -> a -> a) -> Identity a -> a Source

foldl1 :: (a -> a -> a) -> Identity a -> a Source

toList :: Identity a -> [a] Source

null :: Identity a -> Bool Source

length :: Identity a -> Int Source

elem :: Eq a => a -> Identity a -> Bool Source

maximum :: Ord a => Identity a -> a Source

minimum :: Ord a => Identity a -> a Source

sum :: Num a => Identity a -> a Source

product :: Num a => Identity a -> a Source

Foldable ZipList

Since: base-4.9.0.0

Instance details

Defined in Control.Applicative

Methods

fold :: Monoid m => ZipList m -> m Source

foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source

foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source

foldr :: (a -> b -> b) -> b -> ZipList a -> b Source

foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source

foldl :: (b -> a -> b) -> b -> ZipList a -> b Source

foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source

foldr1 :: (a -> a -> a) -> ZipList a -> a Source

foldl1 :: (a -> a -> a) -> ZipList a -> a Source

toList :: ZipList a -> [a] Source

null :: ZipList a -> Bool Source

length :: ZipList a -> Int Source

elem :: Eq a => a -> ZipList a -> Bool Source

maximum :: Ord a => ZipList a -> a Source

minimum :: Ord a => ZipList a -> a Source

sum :: Num a => ZipList a -> a Source

product :: Num a => ZipList a -> a Source

Foldable Option

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => Option m -> m Source

foldMap :: Monoid m => (a -> m) -> Option a -> m Source

foldMap' :: Monoid m => (a -> m) -> Option a -> m Source

foldr :: (a -> b -> b) -> b -> Option a -> b Source

foldr' :: (a -> b -> b) -> b -> Option a -> b Source

foldl :: (b -> a -> b) -> b -> Option a -> b Source

foldl' :: (b -> a -> b) -> b -> Option a -> b Source

foldr1 :: (a -> a -> a) -> Option a -> a Source

foldl1 :: (a -> a -> a) -> Option a -> a Source

toList :: Option a -> [a] Source

null :: Option a -> Bool Source

length :: Option a -> Int Source

elem :: Eq a => a -> Option a -> Bool Source

maximum :: Ord a => Option a -> a Source

minimum :: Ord a => Option a -> a Source

sum :: Num a => Option a -> a Source

product :: Num a => Option a -> a Source

Foldable Last

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => Last m -> m Source

foldMap :: Monoid m => (a -> m) -> Last a -> m Source

foldMap' :: Monoid m => (a -> m) -> Last a -> m Source

foldr :: (a -> b -> b) -> b -> Last a -> b Source

foldr' :: (a -> b -> b) -> b -> Last a -> b Source

foldl :: (b -> a -> b) -> b -> Last a -> b Source

foldl' :: (b -> a -> b) -> b -> Last a -> b Source

foldr1 :: (a -> a -> a) -> Last a -> a Source

foldl1 :: (a -> a -> a) -> Last a -> a Source

toList :: Last a -> [a] Source

null :: Last a -> Bool Source

length :: Last a -> Int Source

elem :: Eq a => a -> Last a -> Bool Source

maximum :: Ord a => Last a -> a Source

minimum :: Ord a => Last a -> a Source

sum :: Num a => Last a -> a Source

product :: Num a => Last a -> a Source

Foldable First

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => First m -> m Source

foldMap :: Monoid m => (a -> m) -> First a -> m Source

foldMap' :: Monoid m => (a -> m) -> First a -> m Source

foldr :: (a -> b -> b) -> b -> First a -> b Source

foldr' :: (a -> b -> b) -> b -> First a -> b Source

foldl :: (b -> a -> b) -> b -> First a -> b Source

foldl' :: (b -> a -> b) -> b -> First a -> b Source

foldr1 :: (a -> a -> a) -> First a -> a Source

foldl1 :: (a -> a -> a) -> First a -> a Source

toList :: First a -> [a] Source

null :: First a -> Bool Source

length :: First a -> Int Source

elem :: Eq a => a -> First a -> Bool Source

maximum :: Ord a => First a -> a Source

minimum :: Ord a => First a -> a Source

sum :: Num a => First a -> a Source

product :: Num a => First a -> a Source

Foldable Max

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => Max m -> m Source

foldMap :: Monoid m => (a -> m) -> Max a -> m Source

foldMap' :: Monoid m => (a -> m) -> Max a -> m Source

foldr :: (a -> b -> b) -> b -> Max a -> b Source

foldr' :: (a -> b -> b) -> b -> Max a -> b Source

foldl :: (b -> a -> b) -> b -> Max a -> b Source

foldl' :: (b -> a -> b) -> b -> Max a -> b Source

foldr1 :: (a -> a -> a) -> Max a -> a Source

foldl1 :: (a -> a -> a) -> Max a -> a Source

toList :: Max a -> [a] Source

null :: Max a -> Bool Source

length :: Max a -> Int Source

elem :: Eq a => a -> Max a -> Bool Source

maximum :: Ord a => Max a -> a Source

minimum :: Ord a => Max a -> a Source

sum :: Num a => Max a -> a Source

product :: Num a => Max a -> a Source

Foldable Min

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => Min m -> m Source

foldMap :: Monoid m => (a -> m) -> Min a -> m Source

foldMap' :: Monoid m => (a -> m) -> Min a -> m Source

foldr :: (a -> b -> b) -> b -> Min a -> b Source

foldr' :: (a -> b -> b) -> b -> Min a -> b Source

foldl :: (b -> a -> b) -> b -> Min a -> b Source

foldl' :: (b -> a -> b) -> b -> Min a -> b Source

foldr1 :: (a -> a -> a) -> Min a -> a Source

foldl1 :: (a -> a -> a) -> Min a -> a Source

toList :: Min a -> [a] Source

null :: Min a -> Bool Source

length :: Min a -> Int Source

elem :: Eq a => a -> Min a -> Bool Source

maximum :: Ord a => Min a -> a Source

minimum :: Ord a => Min a -> a Source

sum :: Num a => Min a -> a Source

product :: Num a => Min a -> a Source

Foldable Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

fold :: Monoid m => Complex m -> m Source

foldMap :: Monoid m => (a -> m) -> Complex a -> m Source

foldMap' :: Monoid m => (a -> m) -> Complex a -> m Source

foldr :: (a -> b -> b) -> b -> Complex a -> b Source

foldr' :: (a -> b -> b) -> b -> Complex a -> b Source

foldl :: (b -> a -> b) -> b -> Complex a -> b Source

foldl' :: (b -> a -> b) -> b -> Complex a -> b Source

foldr1 :: (a -> a -> a) -> Complex a -> a Source

foldl1 :: (a -> a -> a) -> Complex a -> a Source

toList :: Complex a -> [a] Source

null :: Complex a -> Bool Source

length :: Complex a -> Int Source

elem :: Eq a => a -> Complex a -> Bool Source

maximum :: Ord a => Complex a -> a Source

minimum :: Ord a => Complex a -> a Source

sum :: Num a => Complex a -> a Source

product :: Num a => Complex a -> a Source

Foldable (Either a)

Since: base-4.7.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Either a m -> m Source

foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source

foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source

foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source

foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source

foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source

foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source

foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source

foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source

toList :: Either a a0 -> [a0] Source

null :: Either a a0 -> Bool Source

length :: Either a a0 -> Int Source

elem :: Eq a0 => a0 -> Either a a0 -> Bool Source

maximum :: Ord a0 => Either a a0 -> a0 Source

minimum :: Ord a0 => Either a a0 -> a0 Source

sum :: Num a0 => Either a a0 -> a0 Source

product :: Num a0 => Either a a0 -> a0 Source

Foldable (V1 :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => V1 m -> m Source

foldMap :: Monoid m => (a -> m) -> V1 a -> m Source

foldMap' :: Monoid m => (a -> m) -> V1 a -> m Source

foldr :: (a -> b -> b) -> b -> V1 a -> b Source

foldr' :: (a -> b -> b) -> b -> V1 a -> b Source

foldl :: (b -> a -> b) -> b -> V1 a -> b Source

foldl' :: (b -> a -> b) -> b -> V1 a -> b Source

foldr1 :: (a -> a -> a) -> V1 a -> a Source

foldl1 :: (a -> a -> a) -> V1 a -> a Source

toList :: V1 a -> [a] Source

null :: V1 a -> Bool Source

length :: V1 a -> Int Source

elem :: Eq a => a -> V1 a -> Bool Source

maximum :: Ord a => V1 a -> a Source

minimum :: Ord a => V1 a -> a Source

sum :: Num a => V1 a -> a Source

product :: Num a => V1 a -> a Source

Foldable (U1 :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => U1 m -> m Source

foldMap :: Monoid m => (a -> m) -> U1 a -> m Source

foldMap' :: Monoid m => (a -> m) -> U1 a -> m Source

foldr :: (a -> b -> b) -> b -> U1 a -> b Source

foldr' :: (a -> b -> b) -> b -> U1 a -> b Source

foldl :: (b -> a -> b) -> b -> U1 a -> b Source

foldl' :: (b -> a -> b) -> b -> U1 a -> b Source

foldr1 :: (a -> a -> a) -> U1 a -> a Source

foldl1 :: (a -> a -> a) -> U1 a -> a Source

toList :: U1 a -> [a] Source

null :: U1 a -> Bool Source

length :: U1 a -> Int Source

elem :: Eq a => a -> U1 a -> Bool Source

maximum :: Ord a => U1 a -> a Source

minimum :: Ord a => U1 a -> a Source

sum :: Num a => U1 a -> a Source

product :: Num a => U1 a -> a Source

Foldable (UAddr :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UAddr m -> m Source

foldMap :: Monoid m => (a -> m) -> UAddr a -> m Source

foldMap' :: Monoid m => (a -> m) -> UAddr a -> m Source

foldr :: (a -> b -> b) -> b -> UAddr a -> b Source

foldr' :: (a -> b -> b) -> b -> UAddr a -> b Source

foldl :: (b -> a -> b) -> b -> UAddr a -> b Source

foldl' :: (b -> a -> b) -> b -> UAddr a -> b Source

foldr1 :: (a -> a -> a) -> UAddr a -> a Source

foldl1 :: (a -> a -> a) -> UAddr a -> a Source

toList :: UAddr a -> [a] Source

null :: UAddr a -> Bool Source

length :: UAddr a -> Int Source

elem :: Eq a => a -> UAddr a -> Bool Source

maximum :: Ord a => UAddr a -> a Source

minimum :: Ord a => UAddr a -> a Source

sum :: Num a => UAddr a -> a Source

product :: Num a => UAddr a -> a Source

Foldable (UChar :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UChar m -> m Source

foldMap :: Monoid m => (a -> m) -> UChar a -> m Source

foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source

foldr :: (a -> b -> b) -> b -> UChar a -> b Source

foldr' :: (a -> b -> b) -> b -> UChar a -> b Source

foldl :: (b -> a -> b) -> b -> UChar a -> b Source

foldl' :: (b -> a -> b) -> b -> UChar a -> b Source

foldr1 :: (a -> a -> a) -> UChar a -> a Source

foldl1 :: (a -> a -> a) -> UChar a -> a Source

toList :: UChar a -> [a] Source

null :: UChar a -> Bool Source

length :: UChar a -> Int Source

elem :: Eq a => a -> UChar a -> Bool Source

maximum :: Ord a => UChar a -> a Source

minimum :: Ord a => UChar a -> a Source

sum :: Num a => UChar a -> a Source

product :: Num a => UChar a -> a Source

Foldable (UDouble :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UDouble m -> m Source

foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source

foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source

foldr :: (a -> b -> b) -> b -> UDouble a -> b Source

foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source

foldl :: (b -> a -> b) -> b -> UDouble a -> b Source

foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source

foldr1 :: (a -> a -> a) -> UDouble a -> a Source

foldl1 :: (a -> a -> a) -> UDouble a -> a Source

toList :: UDouble a -> [a] Source

null :: UDouble a -> Bool Source

length :: UDouble a -> Int Source

elem :: Eq a => a -> UDouble a -> Bool Source

maximum :: Ord a => UDouble a -> a Source

minimum :: Ord a => UDouble a -> a Source

sum :: Num a => UDouble a -> a Source

product :: Num a => UDouble a -> a Source

Foldable (UFloat :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UFloat m -> m Source

foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source

foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source

foldr :: (a -> b -> b) -> b -> UFloat a -> b Source

foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source

foldl :: (b -> a -> b) -> b -> UFloat a -> b Source

foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source

foldr1 :: (a -> a -> a) -> UFloat a -> a Source

foldl1 :: (a -> a -> a) -> UFloat a -> a Source

toList :: UFloat a -> [a] Source

null :: UFloat a -> Bool Source

length :: UFloat a -> Int Source

elem :: Eq a => a -> UFloat a -> Bool Source

maximum :: Ord a => UFloat a -> a Source

minimum :: Ord a => UFloat a -> a Source

sum :: Num a => UFloat a -> a Source

product :: Num a => UFloat a -> a Source

Foldable (UInt :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UInt m -> m Source

foldMap :: Monoid m => (a -> m) -> UInt a -> m Source

foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source

foldr :: (a -> b -> b) -> b -> UInt a -> b Source

foldr' :: (a -> b -> b) -> b -> UInt a -> b Source

foldl :: (b -> a -> b) -> b -> UInt a -> b Source

foldl' :: (b -> a -> b) -> b -> UInt a -> b Source

foldr1 :: (a -> a -> a) -> UInt a -> a Source

foldl1 :: (a -> a -> a) -> UInt a -> a Source

toList :: UInt a -> [a] Source

null :: UInt a -> Bool Source

length :: UInt a -> Int Source

elem :: Eq a => a -> UInt a -> Bool Source

maximum :: Ord a => UInt a -> a Source

minimum :: Ord a => UInt a -> a Source

sum :: Num a => UInt a -> a Source

product :: Num a => UInt a -> a Source

Foldable (UWord :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => UWord m -> m Source

foldMap :: Monoid m => (a -> m) -> UWord a -> m Source

foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source

foldr :: (a -> b -> b) -> b -> UWord a -> b Source

foldr' :: (a -> b -> b) -> b -> UWord a -> b Source

foldl :: (b -> a -> b) -> b -> UWord a -> b Source

foldl' :: (b -> a -> b) -> b -> UWord a -> b Source

foldr1 :: (a -> a -> a) -> UWord a -> a Source

foldl1 :: (a -> a -> a) -> UWord a -> a Source

toList :: UWord a -> [a] Source

null :: UWord a -> Bool Source

length :: UWord a -> Int Source

elem :: Eq a => a -> UWord a -> Bool Source

maximum :: Ord a => UWord a -> a Source

minimum :: Ord a => UWord a -> a Source

sum :: Num a => UWord a -> a Source

product :: Num a => UWord a -> a Source

Foldable ((,) a)

Since: base-4.7.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => (a, m) -> m Source

foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m Source

foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m Source

foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b Source

foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b Source

foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b Source

foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b Source

foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source

foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source

toList :: (a, a0) -> [a0] Source

null :: (a, a0) -> Bool Source

length :: (a, a0) -> Int Source

elem :: Eq a0 => a0 -> (a, a0) -> Bool Source

maximum :: Ord a0 => (a, a0) -> a0 Source

minimum :: Ord a0 => (a, a0) -> a0 Source

sum :: Num a0 => (a, a0) -> a0 Source

product :: Num a0 => (a, a0) -> a0 Source

Foldable (Array i)

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Array i m -> m Source

foldMap :: Monoid m => (a -> m) -> Array i a -> m Source

foldMap' :: Monoid m => (a -> m) -> Array i a -> m Source

foldr :: (a -> b -> b) -> b -> Array i a -> b Source

foldr' :: (a -> b -> b) -> b -> Array i a -> b Source

foldl :: (b -> a -> b) -> b -> Array i a -> b Source

foldl' :: (b -> a -> b) -> b -> Array i a -> b Source

foldr1 :: (a -> a -> a) -> Array i a -> a Source

foldl1 :: (a -> a -> a) -> Array i a -> a Source

toList :: Array i a -> [a] Source

null :: Array i a -> Bool Source

length :: Array i a -> Int Source

elem :: Eq a => a -> Array i a -> Bool Source

maximum :: Ord a => Array i a -> a Source

minimum :: Ord a => Array i a -> a Source

sum :: Num a => Array i a -> a Source

product :: Num a => Array i a -> a Source

Foldable (Proxy :: Type -> Type)

Since: base-4.7.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Proxy m -> m Source

foldMap :: Monoid m => (a -> m) -> Proxy a -> m Source

foldMap' :: Monoid m => (a -> m) -> Proxy a -> m Source

foldr :: (a -> b -> b) -> b -> Proxy a -> b Source

foldr' :: (a -> b -> b) -> b -> Proxy a -> b Source

foldl :: (b -> a -> b) -> b -> Proxy a -> b Source

foldl' :: (b -> a -> b) -> b -> Proxy a -> b Source

foldr1 :: (a -> a -> a) -> Proxy a -> a Source

foldl1 :: (a -> a -> a) -> Proxy a -> a Source

toList :: Proxy a -> [a] Source

null :: Proxy a -> Bool Source

length :: Proxy a -> Int Source

elem :: Eq a => a -> Proxy a -> Bool Source

maximum :: Ord a => Proxy a -> a Source

minimum :: Ord a => Proxy a -> a Source

sum :: Num a => Proxy a -> a Source

product :: Num a => Proxy a -> a Source

Foldable (Arg a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

fold :: Monoid m => Arg a m -> m Source

foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source

foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source

foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source

foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source

foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source

foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source

foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source

foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source

toList :: Arg a a0 -> [a0] Source

null :: Arg a a0 -> Bool Source

length :: Arg a a0 -> Int Source

elem :: Eq a0 => a0 -> Arg a a0 -> Bool Source

maximum :: Ord a0 => Arg a a0 -> a0 Source

minimum :: Ord a0 => Arg a a0 -> a0 Source

sum :: Num a0 => Arg a a0 -> a0 Source

product :: Num a0 => Arg a a0 -> a0 Source

Foldable f => Foldable (Rec1 f)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Rec1 f m -> m Source

foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m Source

foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m Source

foldr :: (a -> b -> b) -> b -> Rec1 f a -> b Source

foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b Source

foldl :: (b -> a -> b) -> b -> Rec1 f a -> b Source

foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b Source

foldr1 :: (a -> a -> a) -> Rec1 f a -> a Source

foldl1 :: (a -> a -> a) -> Rec1 f a -> a Source

toList :: Rec1 f a -> [a] Source

null :: Rec1 f a -> Bool Source

length :: Rec1 f a -> Int Source

elem :: Eq a => a -> Rec1 f a -> Bool Source

maximum :: Ord a => Rec1 f a -> a Source

minimum :: Ord a => Rec1 f a -> a Source

sum :: Num a => Rec1 f a -> a Source

product :: Num a => Rec1 f a -> a Source

Foldable f => Foldable (Alt f)

Since: base-4.12.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Alt f m -> m Source

foldMap :: Monoid m => (a -> m) -> Alt f a -> m Source

foldMap' :: Monoid m => (a -> m) -> Alt f a -> m Source

foldr :: (a -> b -> b) -> b -> Alt f a -> b Source

foldr' :: (a -> b -> b) -> b -> Alt f a -> b Source

foldl :: (b -> a -> b) -> b -> Alt f a -> b Source

foldl' :: (b -> a -> b) -> b -> Alt f a -> b Source

foldr1 :: (a -> a -> a) -> Alt f a -> a Source

foldl1 :: (a -> a -> a) -> Alt f a -> a Source

toList :: Alt f a -> [a] Source

null :: Alt f a -> Bool Source

length :: Alt f a -> Int Source

elem :: Eq a => a -> Alt f a -> Bool Source

maximum :: Ord a => Alt f a -> a Source

minimum :: Ord a => Alt f a -> a Source

sum :: Num a => Alt f a -> a Source

product :: Num a => Alt f a -> a Source

Foldable f => Foldable (Ap f)

Since: base-4.12.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Ap f m -> m Source

foldMap :: Monoid m => (a -> m) -> Ap f a -> m Source

foldMap' :: Monoid m => (a -> m) -> Ap f a -> m Source

foldr :: (a -> b -> b) -> b -> Ap f a -> b Source

foldr' :: (a -> b -> b) -> b -> Ap f a -> b Source

foldl :: (b -> a -> b) -> b -> Ap f a -> b Source

foldl' :: (b -> a -> b) -> b -> Ap f a -> b Source

foldr1 :: (a -> a -> a) -> Ap f a -> a Source

foldl1 :: (a -> a -> a) -> Ap f a -> a Source

toList :: Ap f a -> [a] Source

null :: Ap f a -> Bool Source

length :: Ap f a -> Int Source

elem :: Eq a => a -> Ap f a -> Bool Source

maximum :: Ord a => Ap f a -> a Source

minimum :: Ord a => Ap f a -> a Source

sum :: Num a => Ap f a -> a Source

product :: Num a => Ap f a -> a Source

Foldable (Const m :: Type -> Type)

Since: base-4.7.0.0

Instance details

Defined in Data.Functor.Const

Methods

fold :: Monoid m0 => Const m m0 -> m0 Source

foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source

foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source

foldr :: (a -> b -> b) -> b -> Const m a -> b Source

foldr' :: (a -> b -> b) -> b -> Const m a -> b Source

foldl :: (b -> a -> b) -> b -> Const m a -> b Source

foldl' :: (b -> a -> b) -> b -> Const m a -> b Source

foldr1 :: (a -> a -> a) -> Const m a -> a Source

foldl1 :: (a -> a -> a) -> Const m a -> a Source

toList :: Const m a -> [a] Source

null :: Const m a -> Bool Source

length :: Const m a -> Int Source

elem :: Eq a => a -> Const m a -> Bool Source

maximum :: Ord a => Const m a -> a Source

minimum :: Ord a => Const m a -> a Source

sum :: Num a => Const m a -> a Source

product :: Num a => Const m a -> a Source

Foldable (K1 i c :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => K1 i c m -> m Source

foldMap :: Monoid m => (a -> m) -> K1 i c a -> m Source

foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m Source

foldr :: (a -> b -> b) -> b -> K1 i c a -> b Source

foldr' :: (a -> b -> b) -> b -> K1 i c a -> b Source

foldl :: (b -> a -> b) -> b -> K1 i c a -> b Source

foldl' :: (b -> a -> b) -> b -> K1 i c a -> b Source

foldr1 :: (a -> a -> a) -> K1 i c a -> a Source

foldl1 :: (a -> a -> a) -> K1 i c a -> a Source

toList :: K1 i c a -> [a] Source

null :: K1 i c a -> Bool Source

length :: K1 i c a -> Int Source

elem :: Eq a => a -> K1 i c a -> Bool Source

maximum :: Ord a => K1 i c a -> a Source

minimum :: Ord a => K1 i c a -> a Source

sum :: Num a => K1 i c a -> a Source

product :: Num a => K1 i c a -> a Source

(Foldable f, Foldable g) => Foldable (f :+: g)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => (f :+: g) m -> m Source

foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m Source

foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m Source

foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b Source

foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b Source

foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b Source

foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b Source

foldr1 :: (a -> a -> a) -> (f :+: g) a -> a Source

foldl1 :: (a -> a -> a) -> (f :+: g) a -> a Source

toList :: (f :+: g) a -> [a] Source

null :: (f :+: g) a -> Bool Source

length :: (f :+: g) a -> Int Source

elem :: Eq a => a -> (f :+: g) a -> Bool Source

maximum :: Ord a => (f :+: g) a -> a Source

minimum :: Ord a => (f :+: g) a -> a Source

sum :: Num a => (f :+: g) a -> a Source

product :: Num a => (f :+: g) a -> a Source

(Foldable f, Foldable g) => Foldable (f :*: g)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => (f :*: g) m -> m Source

foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m Source

foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m Source

foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b Source

foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b Source

foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b Source

foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b Source

foldr1 :: (a -> a -> a) -> (f :*: g) a -> a Source

foldl1 :: (a -> a -> a) -> (f :*: g) a -> a Source

toList :: (f :*: g) a -> [a] Source

null :: (f :*: g) a -> Bool Source

length :: (f :*: g) a -> Int Source

elem :: Eq a => a -> (f :*: g) a -> Bool Source

maximum :: Ord a => (f :*: g) a -> a Source

minimum :: Ord a => (f :*: g) a -> a Source

sum :: Num a => (f :*: g) a -> a Source

product :: Num a => (f :*: g) a -> a Source

(Foldable f, Foldable g) => Foldable (Sum f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

fold :: Monoid m => Sum f g m -> m Source

foldMap :: Monoid m => (a -> m) -> Sum f g a -> m Source

foldMap' :: Monoid m => (a -> m) -> Sum f g a -> m Source

foldr :: (a -> b -> b) -> b -> Sum f g a -> b Source

foldr' :: (a -> b -> b) -> b -> Sum f g a -> b Source

foldl :: (b -> a -> b) -> b -> Sum f g a -> b Source

foldl' :: (b -> a -> b) -> b -> Sum f g a -> b Source

foldr1 :: (a -> a -> a) -> Sum f g a -> a Source

foldl1 :: (a -> a -> a) -> Sum f g a -> a Source

toList :: Sum f g a -> [a] Source

null :: Sum f g a -> Bool Source

length :: Sum f g a -> Int Source

elem :: Eq a => a -> Sum f g a -> Bool Source

maximum :: Ord a => Sum f g a -> a Source

minimum :: Ord a => Sum f g a -> a Source

sum :: Num a => Sum f g a -> a Source

product :: Num a => Sum f g a -> a Source

(Foldable f, Foldable g) => Foldable (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

fold :: Monoid m => Product f g m -> m Source

foldMap :: Monoid m => (a -> m) -> Product f g a -> m Source

foldMap' :: Monoid m => (a -> m) -> Product f g a -> m Source

foldr :: (a -> b -> b) -> b -> Product f g a -> b Source

foldr' :: (a -> b -> b) -> b -> Product f g a -> b Source

foldl :: (b -> a -> b) -> b -> Product f g a -> b Source

foldl' :: (b -> a -> b) -> b -> Product f g a -> b Source

foldr1 :: (a -> a -> a) -> Product f g a -> a Source

foldl1 :: (a -> a -> a) -> Product f g a -> a Source

toList :: Product f g a -> [a] Source

null :: Product f g a -> Bool Source

length :: Product f g a -> Int Source

elem :: Eq a => a -> Product f g a -> Bool Source

maximum :: Ord a => Product f g a -> a Source

minimum :: Ord a => Product f g a -> a Source

sum :: Num a => Product f g a -> a Source

product :: Num a => Product f g a -> a Source

Foldable f => Foldable (M1 i c f)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => M1 i c f m -> m Source

foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m Source

foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m Source

foldr :: (a -> b -> b) -> b -> M1 i c f a -> b Source

foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b Source

foldl :: (b -> a -> b) -> b -> M1 i c f a -> b Source

foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b Source

foldr1 :: (a -> a -> a) -> M1 i c f a -> a Source

foldl1 :: (a -> a -> a) -> M1 i c f a -> a Source

toList :: M1 i c f a -> [a] Source

null :: M1 i c f a -> Bool Source

length :: M1 i c f a -> Int Source

elem :: Eq a => a -> M1 i c f a -> Bool Source

maximum :: Ord a => M1 i c f a -> a Source

minimum :: Ord a => M1 i c f a -> a Source

sum :: Num a => M1 i c f a -> a Source

product :: Num a => M1 i c f a -> a Source

(Foldable f, Foldable g) => Foldable (f :.: g)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => (f :.: g) m -> m Source

foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m Source

foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m Source

foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b Source

foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b Source

foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b Source

foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b Source

foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source

foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source

toList :: (f :.: g) a -> [a] Source

null :: (f :.: g) a -> Bool Source

length :: (f :.: g) a -> Int Source

elem :: Eq a => a -> (f :.: g) a -> Bool Source

maximum :: Ord a => (f :.: g) a -> a Source

minimum :: Ord a => (f :.: g) a -> a Source

sum :: Num a => (f :.: g) a -> a Source

product :: Num a => (f :.: g) a -> a Source

(Foldable f, Foldable g) => Foldable (Compose f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Compose

Methods

fold :: Monoid m => Compose f g m -> m Source

foldMap :: Monoid m => (a -> m) -> Compose f g a -> m Source

foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m Source

foldr :: (a -> b -> b) -> b -> Compose f g a -> b Source

foldr' :: (a -> b -> b) -> b -> Compose f g a -> b Source

foldl :: (b -> a -> b) -> b -> Compose f g a -> b Source

foldl' :: (b -> a -> b) -> b -> Compose f g a -> b Source

foldr1 :: (a -> a -> a) -> Compose f g a -> a Source

foldl1 :: (a -> a -> a) -> Compose f g a -> a Source

toList :: Compose f g a -> [a] Source

null :: Compose f g a -> Bool Source

length :: Compose f g a -> Int Source

elem :: Eq a => a -> Compose f g a -> Bool Source

maximum :: Ord a => Compose f g a -> a Source

minimum :: Ord a => Compose f g a -> a Source

sum :: Num a => Compose f g a -> a Source

product :: Num a => Compose f g a -> a Source

Special biased folds

foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b Source

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 b Source

Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.

Folding actions

Applicative actions

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 see traverse.

for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () Source

for_ is traverse_ with its arguments flipped. For a version that doesn't ignore the results see for.

>>> for_ [1..4] print
1
2
3
4

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 see sequenceA.

asum :: (Foldable t, Alternative f) => t (f a) -> f a Source

The sum of a collection of actions, generalizing concat.

>>> asum [Just "Hello", Nothing, Just "World"]
Just "Hello"

Monadic actions

mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () Source

Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see mapM.

As of base 4.8.0.0, mapM_ is just traverse_, specialized to Monad.

forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () Source

forM_ is mapM_ with its arguments flipped. For a version that doesn't ignore the results see forM.

As of base 4.8.0.0, forM_ is just for_, specialized to Monad.

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 see sequence.

As of base 4.8.0.0, sequence_ is just sequenceA_, specialized to Monad.

msum :: (Foldable t, MonadPlus m) => t (m a) -> m a Source

The sum of a collection of actions, generalizing concat. As of base 4.8.0.0, msum is just asum, specialized to MonadPlus.

Specialized folds

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.

and :: Foldable t => t Bool -> Bool Source

and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.

or :: Foldable t => t Bool -> Bool Source

or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.

any :: Foldable t => (a -> Bool) -> t a -> Bool Source

Determines whether any element of the structure satisfies the predicate.

all :: Foldable t => (a -> Bool) -> t a -> Bool Source

Determines whether all elements of the structure satisfy the predicate.

maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a Source

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

minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a Source

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

Searches

notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 Source

notElem is the negation of elem.

find :: Foldable t => (a -> Bool) -> t a -> Maybe a Source

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.10.2/docs/html/libraries/base-4.14.1.0/Data-Foldable.html