papa-base-export-0.4: Prelude with only useful functions

Papa.Base.Export.Data.Foldable

Synopsis

# Documentation

class Foldable (t :: * -> *) where #

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

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

Methods

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

Combine the elements of a structure using a monoid.

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

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

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

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 #

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

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

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

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

toList :: t a -> [a] #

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

null :: t a -> Bool #

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.

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

Does the element occur in the structure?

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

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

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

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

Instances

 Foldable [] Since: 2.1 Methodsfold :: Monoid m => [m] -> m #foldMap :: Monoid m => (a -> m) -> [a] -> m #foldr :: (a -> b -> b) -> b -> [a] -> b #foldr' :: (a -> b -> b) -> b -> [a] -> b #foldl :: (b -> a -> b) -> b -> [a] -> b #foldl' :: (b -> a -> b) -> b -> [a] -> b #foldr1 :: (a -> a -> a) -> [a] -> a #foldl1 :: (a -> a -> a) -> [a] -> a #toList :: [a] -> [a] #null :: [a] -> Bool #length :: [a] -> Int #elem :: Eq a => a -> [a] -> Bool #maximum :: Ord a => [a] -> a #minimum :: Ord a => [a] -> a #sum :: Num a => [a] -> a #product :: Num a => [a] -> a # Since: 2.1 Methodsfold :: Monoid m => Maybe m -> m #foldMap :: Monoid m => (a -> m) -> Maybe a -> m #foldr :: (a -> b -> b) -> b -> Maybe a -> b #foldr' :: (a -> b -> b) -> b -> Maybe a -> b #foldl :: (b -> a -> b) -> b -> Maybe a -> b #foldl' :: (b -> a -> b) -> b -> Maybe a -> b #foldr1 :: (a -> a -> a) -> Maybe a -> a #foldl1 :: (a -> a -> a) -> Maybe a -> a #toList :: Maybe a -> [a] #null :: Maybe a -> Bool #length :: Maybe a -> Int #elem :: Eq a => a -> Maybe a -> Bool #maximum :: Ord a => Maybe a -> a #minimum :: Ord a => Maybe a -> a #sum :: Num a => Maybe a -> a #product :: Num a => Maybe a -> a # Methodsfold :: Monoid m => Par1 m -> m #foldMap :: Monoid m => (a -> m) -> Par1 a -> m #foldr :: (a -> b -> b) -> b -> Par1 a -> b #foldr' :: (a -> b -> b) -> b -> Par1 a -> b #foldl :: (b -> a -> b) -> b -> Par1 a -> b #foldl' :: (b -> a -> b) -> b -> Par1 a -> b #foldr1 :: (a -> a -> a) -> Par1 a -> a #foldl1 :: (a -> a -> a) -> Par1 a -> a #toList :: Par1 a -> [a] #null :: Par1 a -> Bool #length :: Par1 a -> Int #elem :: Eq a => a -> Par1 a -> Bool #maximum :: Ord a => Par1 a -> a #minimum :: Ord a => Par1 a -> a #sum :: Num a => Par1 a -> a #product :: Num a => Par1 a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => Min m -> m #foldMap :: Monoid m => (a -> m) -> Min a -> m #foldr :: (a -> b -> b) -> b -> Min a -> b #foldr' :: (a -> b -> b) -> b -> Min a -> b #foldl :: (b -> a -> b) -> b -> Min a -> b #foldl' :: (b -> a -> b) -> b -> Min a -> b #foldr1 :: (a -> a -> a) -> Min a -> a #foldl1 :: (a -> a -> a) -> Min a -> a #toList :: Min a -> [a] #null :: Min a -> Bool #length :: Min a -> Int #elem :: Eq a => a -> Min a -> Bool #maximum :: Ord a => Min a -> a #minimum :: Ord a => Min a -> a #sum :: Num a => Min a -> a #product :: Num a => Min a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => Max m -> m #foldMap :: Monoid m => (a -> m) -> Max a -> m #foldr :: (a -> b -> b) -> b -> Max a -> b #foldr' :: (a -> b -> b) -> b -> Max a -> b #foldl :: (b -> a -> b) -> b -> Max a -> b #foldl' :: (b -> a -> b) -> b -> Max a -> b #foldr1 :: (a -> a -> a) -> Max a -> a #foldl1 :: (a -> a -> a) -> Max a -> a #toList :: Max a -> [a] #null :: Max a -> Bool #length :: Max a -> Int #elem :: Eq a => a -> Max a -> Bool #maximum :: Ord a => Max a -> a #minimum :: Ord a => Max a -> a #sum :: Num a => Max a -> a #product :: Num a => Max a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => First m -> m #foldMap :: Monoid m => (a -> m) -> First a -> m #foldr :: (a -> b -> b) -> b -> First a -> b #foldr' :: (a -> b -> b) -> b -> First a -> b #foldl :: (b -> a -> b) -> b -> First a -> b #foldl' :: (b -> a -> b) -> b -> First a -> b #foldr1 :: (a -> a -> a) -> First a -> a #foldl1 :: (a -> a -> a) -> First a -> a #toList :: First a -> [a] #null :: First a -> Bool #length :: First a -> Int #elem :: Eq a => a -> First a -> Bool #maximum :: Ord a => First a -> a #minimum :: Ord a => First a -> a #sum :: Num a => First a -> a #product :: Num a => First a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => Last m -> m #foldMap :: Monoid m => (a -> m) -> Last a -> m #foldr :: (a -> b -> b) -> b -> Last a -> b #foldr' :: (a -> b -> b) -> b -> Last a -> b #foldl :: (b -> a -> b) -> b -> Last a -> b #foldl' :: (b -> a -> b) -> b -> Last a -> b #foldr1 :: (a -> a -> a) -> Last a -> a #foldl1 :: (a -> a -> a) -> Last a -> a #toList :: Last a -> [a] #null :: Last a -> Bool #length :: Last a -> Int #elem :: Eq a => a -> Last a -> Bool #maximum :: Ord a => Last a -> a #minimum :: Ord a => Last a -> a #sum :: Num a => Last a -> a #product :: Num a => Last a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => Option m -> m #foldMap :: Monoid m => (a -> m) -> Option a -> m #foldr :: (a -> b -> b) -> b -> Option a -> b #foldr' :: (a -> b -> b) -> b -> Option a -> b #foldl :: (b -> a -> b) -> b -> Option a -> b #foldl' :: (b -> a -> b) -> b -> Option a -> b #foldr1 :: (a -> a -> a) -> Option a -> a #foldl1 :: (a -> a -> a) -> Option a -> a #toList :: Option a -> [a] #null :: Option a -> Bool #length :: Option a -> Int #elem :: Eq a => a -> Option a -> Bool #maximum :: Ord a => Option a -> a #minimum :: Ord a => Option a -> a #sum :: Num a => Option a -> a #product :: Num a => Option a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => NonEmpty m -> m #foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m #foldr :: (a -> b -> b) -> b -> NonEmpty a -> b #foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b #foldl :: (b -> a -> b) -> b -> NonEmpty a -> b #foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b #foldr1 :: (a -> a -> a) -> NonEmpty a -> a #foldl1 :: (a -> a -> a) -> NonEmpty a -> a #toList :: NonEmpty a -> [a] #null :: NonEmpty a -> Bool #length :: NonEmpty a -> Int #elem :: Eq a => a -> NonEmpty a -> Bool #maximum :: Ord a => NonEmpty a -> a #minimum :: Ord a => NonEmpty a -> a #sum :: Num a => NonEmpty a -> a #product :: Num a => NonEmpty a -> a # Methodsfold :: Monoid m => ZipList m -> m #foldMap :: Monoid m => (a -> m) -> ZipList a -> m #foldr :: (a -> b -> b) -> b -> ZipList a -> b #foldr' :: (a -> b -> b) -> b -> ZipList a -> b #foldl :: (b -> a -> b) -> b -> ZipList a -> b #foldl' :: (b -> a -> b) -> b -> ZipList a -> b #foldr1 :: (a -> a -> a) -> ZipList a -> a #foldl1 :: (a -> a -> a) -> ZipList a -> a #toList :: ZipList a -> [a] #null :: ZipList a -> Bool #length :: ZipList a -> Int #elem :: Eq a => a -> ZipList a -> Bool #maximum :: Ord a => ZipList a -> a #minimum :: Ord a => ZipList a -> a #sum :: Num a => ZipList a -> a #product :: Num a => ZipList a -> a # Since: 4.8.0.0 Methodsfold :: Monoid m => Dual m -> m #foldMap :: Monoid m => (a -> m) -> Dual a -> m #foldr :: (a -> b -> b) -> b -> Dual a -> b #foldr' :: (a -> b -> b) -> b -> Dual a -> b #foldl :: (b -> a -> b) -> b -> Dual a -> b #foldl' :: (b -> a -> b) -> b -> Dual a -> b #foldr1 :: (a -> a -> a) -> Dual a -> a #foldl1 :: (a -> a -> a) -> Dual a -> a #toList :: Dual a -> [a] #null :: Dual a -> Bool #length :: Dual a -> Int #elem :: Eq a => a -> Dual a -> Bool #maximum :: Ord a => Dual a -> a #minimum :: Ord a => Dual a -> a #sum :: Num a => Dual a -> a #product :: Num a => Dual a -> a # Since: 4.8.0.0 Methodsfold :: Monoid m => Sum m -> m #foldMap :: Monoid m => (a -> m) -> Sum a -> m #foldr :: (a -> b -> b) -> b -> Sum a -> b #foldr' :: (a -> b -> b) -> b -> Sum a -> b #foldl :: (b -> a -> b) -> b -> Sum a -> b #foldl' :: (b -> a -> b) -> b -> Sum a -> b #foldr1 :: (a -> a -> a) -> Sum a -> a #foldl1 :: (a -> a -> a) -> Sum a -> a #toList :: Sum a -> [a] #null :: Sum a -> Bool #length :: Sum a -> Int #elem :: Eq a => a -> Sum a -> Bool #maximum :: Ord a => Sum a -> a #minimum :: Ord a => Sum a -> a #sum :: Num a => Sum a -> a #product :: Num a => Sum a -> a # Since: 4.8.0.0 Methodsfold :: Monoid m => Product m -> m #foldMap :: Monoid m => (a -> m) -> Product a -> m #foldr :: (a -> b -> b) -> b -> Product a -> b #foldr' :: (a -> b -> b) -> b -> Product a -> b #foldl :: (b -> a -> b) -> b -> Product a -> b #foldl' :: (b -> a -> b) -> b -> Product a -> b #foldr1 :: (a -> a -> a) -> Product a -> a #foldl1 :: (a -> a -> a) -> Product a -> a #toList :: Product a -> [a] #null :: Product a -> Bool #length :: Product a -> Int #elem :: Eq a => a -> Product a -> Bool #maximum :: Ord a => Product a -> a #minimum :: Ord a => Product a -> a #sum :: Num a => Product a -> a #product :: Num a => Product a -> a # Since: 4.8.0.0 Methodsfold :: Monoid m => First m -> m #foldMap :: Monoid m => (a -> m) -> First a -> m #foldr :: (a -> b -> b) -> b -> First a -> b #foldr' :: (a -> b -> b) -> b -> First a -> b #foldl :: (b -> a -> b) -> b -> First a -> b #foldl' :: (b -> a -> b) -> b -> First a -> b #foldr1 :: (a -> a -> a) -> First a -> a #foldl1 :: (a -> a -> a) -> First a -> a #toList :: First a -> [a] #null :: First a -> Bool #length :: First a -> Int #elem :: Eq a => a -> First a -> Bool #maximum :: Ord a => First a -> a #minimum :: Ord a => First a -> a #sum :: Num a => First a -> a #product :: Num a => First a -> a # Since: 4.8.0.0 Methodsfold :: Monoid m => Last m -> m #foldMap :: Monoid m => (a -> m) -> Last a -> m #foldr :: (a -> b -> b) -> b -> Last a -> b #foldr' :: (a -> b -> b) -> b -> Last a -> b #foldl :: (b -> a -> b) -> b -> Last a -> b #foldl' :: (b -> a -> b) -> b -> Last a -> b #foldr1 :: (a -> a -> a) -> Last a -> a #foldl1 :: (a -> a -> a) -> Last a -> a #toList :: Last a -> [a] #null :: Last a -> Bool #length :: Last a -> Int #elem :: Eq a => a -> Last a -> Bool #maximum :: Ord a => Last a -> a #minimum :: Ord a => Last a -> a #sum :: Num a => Last a -> a #product :: Num a => Last a -> a # Since: 4.7.0.0 Methodsfold :: Monoid m => Either a m -> m #foldMap :: Monoid m => (a -> m) -> Either a a -> m #foldr :: (a -> b -> b) -> b -> Either a a -> b #foldr' :: (a -> b -> b) -> b -> Either a a -> b #foldl :: (b -> a -> b) -> b -> Either a a -> b #foldl' :: (b -> a -> b) -> b -> Either a a -> b #foldr1 :: (a -> a -> a) -> Either a a -> a #foldl1 :: (a -> a -> a) -> Either a a -> a #toList :: Either a a -> [a] #null :: Either a a -> Bool #length :: Either a a -> Int #elem :: Eq a => a -> Either a a -> Bool #maximum :: Ord a => Either a a -> a #minimum :: Ord a => Either a a -> a #sum :: Num a => Either a a -> a #product :: Num a => Either a a -> a # Methodsfold :: Monoid m => V1 * m -> m #foldMap :: Monoid m => (a -> m) -> V1 * a -> m #foldr :: (a -> b -> b) -> b -> V1 * a -> b #foldr' :: (a -> b -> b) -> b -> V1 * a -> b #foldl :: (b -> a -> b) -> b -> V1 * a -> b #foldl' :: (b -> a -> b) -> b -> V1 * a -> b #foldr1 :: (a -> a -> a) -> V1 * a -> a #foldl1 :: (a -> a -> a) -> V1 * a -> a #toList :: V1 * a -> [a] #null :: V1 * a -> Bool #length :: V1 * a -> Int #elem :: Eq a => a -> V1 * a -> Bool #maximum :: Ord a => V1 * a -> a #minimum :: Ord a => V1 * a -> a #sum :: Num a => V1 * a -> a #product :: Num a => V1 * a -> a # Since: 4.9.0.0 Methodsfold :: Monoid m => U1 * m -> m #foldMap :: Monoid m => (a -> m) -> U1 * a -> m #foldr :: (a -> b -> b) -> b -> U1 * a -> b #foldr' :: (a -> b -> b) -> b -> U1 * a -> b #foldl :: (b -> a -> b) -> b -> U1 * a -> b #foldl' :: (b -> a -> b) -> b -> U1 * a -> b #foldr1 :: (a -> a -> a) -> U1 * a -> a #foldl1 :: (a -> a -> a) -> U1 * a -> a #toList :: U1 * a -> [a] #null :: U1 * a -> Bool #length :: U1 * a -> Int #elem :: Eq a => a -> U1 * a -> Bool #maximum :: Ord a => U1 * a -> a #minimum :: Ord a => U1 * a -> a #sum :: Num a => U1 * a -> a #product :: Num a => U1 * a -> a # Foldable ((,) a) Since: 4.7.0.0 Methodsfold :: Monoid m => (a, m) -> m #foldMap :: Monoid m => (a -> m) -> (a, a) -> m #foldr :: (a -> b -> b) -> b -> (a, a) -> b #foldr' :: (a -> b -> b) -> b -> (a, a) -> b #foldl :: (b -> a -> b) -> b -> (a, a) -> b #foldl' :: (b -> a -> b) -> b -> (a, a) -> b #foldr1 :: (a -> a -> a) -> (a, a) -> a #foldl1 :: (a -> a -> a) -> (a, a) -> a #toList :: (a, a) -> [a] #null :: (a, a) -> Bool #length :: (a, a) -> Int #elem :: Eq a => a -> (a, a) -> Bool #maximum :: Ord a => (a, a) -> a #minimum :: Ord a => (a, a) -> a #sum :: Num a => (a, a) -> a #product :: Num a => (a, a) -> a # Foldable (Array i) Since: 4.8.0.0 Methodsfold :: Monoid m => Array i m -> m #foldMap :: Monoid m => (a -> m) -> Array i a -> m #foldr :: (a -> b -> b) -> b -> Array i a -> b #foldr' :: (a -> b -> b) -> b -> Array i a -> b #foldl :: (b -> a -> b) -> b -> Array i a -> b #foldl' :: (b -> a -> b) -> b -> Array i a -> b #foldr1 :: (a -> a -> a) -> Array i a -> a #foldl1 :: (a -> a -> a) -> Array i a -> a #toList :: Array i a -> [a] #null :: Array i a -> Bool #length :: Array i a -> Int #elem :: Eq a => a -> Array i a -> Bool #maximum :: Ord a => Array i a -> a #minimum :: Ord a => Array i a -> a #sum :: Num a => Array i a -> a #product :: Num a => Array i a -> a # Foldable (Arg a) Since: 4.9.0.0 Methodsfold :: Monoid m => Arg a m -> m #foldMap :: Monoid m => (a -> m) -> Arg a a -> m #foldr :: (a -> b -> b) -> b -> Arg a a -> b #foldr' :: (a -> b -> b) -> b -> Arg a a -> b #foldl :: (b -> a -> b) -> b -> Arg a a -> b #foldl' :: (b -> a -> b) -> b -> Arg a a -> b #foldr1 :: (a -> a -> a) -> Arg a a -> a #foldl1 :: (a -> a -> a) -> Arg a a -> a #toList :: Arg a a -> [a] #null :: Arg a a -> Bool #length :: Arg a a -> Int #elem :: Eq a => a -> Arg a a -> Bool #maximum :: Ord a => Arg a a -> a #minimum :: Ord a => Arg a a -> a #sum :: Num a => Arg a a -> a #product :: Num a => Arg a a -> a # Since: 4.7.0.0 Methodsfold :: Monoid m => Proxy * m -> m #foldMap :: Monoid m => (a -> m) -> Proxy * a -> m #foldr :: (a -> b -> b) -> b -> Proxy * a -> b #foldr' :: (a -> b -> b) -> b -> Proxy * a -> b #foldl :: (b -> a -> b) -> b -> Proxy * a -> b #foldl' :: (b -> a -> b) -> b -> Proxy * a -> b #foldr1 :: (a -> a -> a) -> Proxy * a -> a #foldl1 :: (a -> a -> a) -> Proxy * a -> a #toList :: Proxy * a -> [a] #null :: Proxy * a -> Bool #length :: Proxy * a -> Int #elem :: Eq a => a -> Proxy * a -> Bool #maximum :: Ord a => Proxy * a -> a #minimum :: Ord a => Proxy * a -> a #sum :: Num a => Proxy * a -> a #product :: Num a => Proxy * a -> a # Foldable f => Foldable (Rec1 * f) Methodsfold :: Monoid m => Rec1 * f m -> m #foldMap :: Monoid m => (a -> m) -> Rec1 * f a -> m #foldr :: (a -> b -> b) -> b -> Rec1 * f a -> b #foldr' :: (a -> b -> b) -> b -> Rec1 * f a -> b #foldl :: (b -> a -> b) -> b -> Rec1 * f a -> b #foldl' :: (b -> a -> b) -> b -> Rec1 * f a -> b #foldr1 :: (a -> a -> a) -> Rec1 * f a -> a #foldl1 :: (a -> a -> a) -> Rec1 * f a -> a #toList :: Rec1 * f a -> [a] #null :: Rec1 * f a -> Bool #length :: Rec1 * f a -> Int #elem :: Eq a => a -> Rec1 * f a -> Bool #maximum :: Ord a => Rec1 * f a -> a #minimum :: Ord a => Rec1 * f a -> a #sum :: Num a => Rec1 * f a -> a #product :: Num a => Rec1 * f a -> a # Methodsfold :: Monoid m => URec * Char m -> m #foldMap :: Monoid m => (a -> m) -> URec * Char a -> m #foldr :: (a -> b -> b) -> b -> URec * Char a -> b #foldr' :: (a -> b -> b) -> b -> URec * Char a -> b #foldl :: (b -> a -> b) -> b -> URec * Char a -> b #foldl' :: (b -> a -> b) -> b -> URec * Char a -> b #foldr1 :: (a -> a -> a) -> URec * Char a -> a #foldl1 :: (a -> a -> a) -> URec * Char a -> a #toList :: URec * Char a -> [a] #null :: URec * Char a -> Bool #length :: URec * Char a -> Int #elem :: Eq a => a -> URec * Char a -> Bool #maximum :: Ord a => URec * Char a -> a #minimum :: Ord a => URec * Char a -> a #sum :: Num a => URec * Char a -> a #product :: Num a => URec * Char a -> a # Methodsfold :: Monoid m => URec * Double m -> m #foldMap :: Monoid m => (a -> m) -> URec * Double a -> m #foldr :: (a -> b -> b) -> b -> URec * Double a -> b #foldr' :: (a -> b -> b) -> b -> URec * Double a -> b #foldl :: (b -> a -> b) -> b -> URec * Double a -> b #foldl' :: (b -> a -> b) -> b -> URec * Double a -> b #foldr1 :: (a -> a -> a) -> URec * Double a -> a #foldl1 :: (a -> a -> a) -> URec * Double a -> a #toList :: URec * Double a -> [a] #null :: URec * Double a -> Bool #length :: URec * Double a -> Int #elem :: Eq a => a -> URec * Double a -> Bool #maximum :: Ord a => URec * Double a -> a #minimum :: Ord a => URec * Double a -> a #sum :: Num a => URec * Double a -> a #product :: Num a => URec * Double a -> a # Methodsfold :: Monoid m => URec * Float m -> m #foldMap :: Monoid m => (a -> m) -> URec * Float a -> m #foldr :: (a -> b -> b) -> b -> URec * Float a -> b #foldr' :: (a -> b -> b) -> b -> URec * Float a -> b #foldl :: (b -> a -> b) -> b -> URec * Float a -> b #foldl' :: (b -> a -> b) -> b -> URec * Float a -> b #foldr1 :: (a -> a -> a) -> URec * Float a -> a #foldl1 :: (a -> a -> a) -> URec * Float a -> a #toList :: URec * Float a -> [a] #null :: URec * Float a -> Bool #length :: URec * Float a -> Int #elem :: Eq a => a -> URec * Float a -> Bool #maximum :: Ord a => URec * Float a -> a #minimum :: Ord a => URec * Float a -> a #sum :: Num a => URec * Float a -> a #product :: Num a => URec * Float a -> a # Methodsfold :: Monoid m => URec * Int m -> m #foldMap :: Monoid m => (a -> m) -> URec * Int a -> m #foldr :: (a -> b -> b) -> b -> URec * Int a -> b #foldr' :: (a -> b -> b) -> b -> URec * Int a -> b #foldl :: (b -> a -> b) -> b -> URec * Int a -> b #foldl' :: (b -> a -> b) -> b -> URec * Int a -> b #foldr1 :: (a -> a -> a) -> URec * Int a -> a #foldl1 :: (a -> a -> a) -> URec * Int a -> a #toList :: URec * Int a -> [a] #null :: URec * Int a -> Bool #length :: URec * Int a -> Int #elem :: Eq a => a -> URec * Int a -> Bool #maximum :: Ord a => URec * Int a -> a #minimum :: Ord a => URec * Int a -> a #sum :: Num a => URec * Int a -> a #product :: Num a => URec * Int a -> a # Methodsfold :: Monoid m => URec * Word m -> m #foldMap :: Monoid m => (a -> m) -> URec * Word a -> m #foldr :: (a -> b -> b) -> b -> URec * Word a -> b #foldr' :: (a -> b -> b) -> b -> URec * Word a -> b #foldl :: (b -> a -> b) -> b -> URec * Word a -> b #foldl' :: (b -> a -> b) -> b -> URec * Word a -> b #foldr1 :: (a -> a -> a) -> URec * Word a -> a #foldl1 :: (a -> a -> a) -> URec * Word a -> a #toList :: URec * Word a -> [a] #null :: URec * Word a -> Bool #length :: URec * Word a -> Int #elem :: Eq a => a -> URec * Word a -> Bool #maximum :: Ord a => URec * Word a -> a #minimum :: Ord a => URec * Word a -> a #sum :: Num a => URec * Word a -> a #product :: Num a => URec * Word a -> a # Foldable (URec * (Ptr ())) Methodsfold :: Monoid m => URec * (Ptr ()) m -> m #foldMap :: Monoid m => (a -> m) -> URec * (Ptr ()) a -> m #foldr :: (a -> b -> b) -> b -> URec * (Ptr ()) a -> b #foldr' :: (a -> b -> b) -> b -> URec * (Ptr ()) a -> b #foldl :: (b -> a -> b) -> b -> URec * (Ptr ()) a -> b #foldl' :: (b -> a -> b) -> b -> URec * (Ptr ()) a -> b #foldr1 :: (a -> a -> a) -> URec * (Ptr ()) a -> a #foldl1 :: (a -> a -> a) -> URec * (Ptr ()) a -> a #toList :: URec * (Ptr ()) a -> [a] #null :: URec * (Ptr ()) a -> Bool #length :: URec * (Ptr ()) a -> Int #elem :: Eq a => a -> URec * (Ptr ()) a -> Bool #maximum :: Ord a => URec * (Ptr ()) a -> a #minimum :: Ord a => URec * (Ptr ()) a -> a #sum :: Num a => URec * (Ptr ()) a -> a #product :: Num a => URec * (Ptr ()) a -> a # Since: 4.7.0.0 Methodsfold :: Monoid m => Const * m m -> m #foldMap :: Monoid m => (a -> m) -> Const * m a -> m #foldr :: (a -> b -> b) -> b -> Const * m a -> b #foldr' :: (a -> b -> b) -> b -> Const * m a -> b #foldl :: (b -> a -> b) -> b -> Const * m a -> b #foldl' :: (b -> a -> b) -> b -> Const * m a -> b #foldr1 :: (a -> a -> a) -> Const * m a -> a #foldl1 :: (a -> a -> a) -> Const * m a -> a #toList :: Const * m a -> [a] #null :: Const * m a -> Bool #length :: Const * m a -> Int #elem :: Eq a => a -> Const * m a -> Bool #maximum :: Ord a => Const * m a -> a #minimum :: Ord a => Const * m a -> a #sum :: Num a => Const * m a -> a #product :: Num a => Const * m a -> a # Foldable (K1 * i c) Methodsfold :: Monoid m => K1 * i c m -> m #foldMap :: Monoid m => (a -> m) -> K1 * i c a -> m #foldr :: (a -> b -> b) -> b -> K1 * i c a -> b #foldr' :: (a -> b -> b) -> b -> K1 * i c a -> b #foldl :: (b -> a -> b) -> b -> K1 * i c a -> b #foldl' :: (b -> a -> b) -> b -> K1 * i c a -> b #foldr1 :: (a -> a -> a) -> K1 * i c a -> a #foldl1 :: (a -> a -> a) -> K1 * i c a -> a #toList :: K1 * i c a -> [a] #null :: K1 * i c a -> Bool #length :: K1 * i c a -> Int #elem :: Eq a => a -> K1 * i c a -> Bool #maximum :: Ord a => K1 * i c a -> a #minimum :: Ord a => K1 * i c a -> a #sum :: Num a => K1 * i c a -> a #product :: Num a => K1 * i c a -> a # (Foldable f, Foldable g) => Foldable ((:+:) * f g) Methodsfold :: Monoid m => (* :+: f) g m -> m #foldMap :: Monoid m => (a -> m) -> (* :+: f) g a -> m #foldr :: (a -> b -> b) -> b -> (* :+: f) g a -> b #foldr' :: (a -> b -> b) -> b -> (* :+: f) g a -> b #foldl :: (b -> a -> b) -> b -> (* :+: f) g a -> b #foldl' :: (b -> a -> b) -> b -> (* :+: f) g a -> b #foldr1 :: (a -> a -> a) -> (* :+: f) g a -> a #foldl1 :: (a -> a -> a) -> (* :+: f) g a -> a #toList :: (* :+: f) g a -> [a] #null :: (* :+: f) g a -> Bool #length :: (* :+: f) g a -> Int #elem :: Eq a => a -> (* :+: f) g a -> Bool #maximum :: Ord a => (* :+: f) g a -> a #minimum :: Ord a => (* :+: f) g a -> a #sum :: Num a => (* :+: f) g a -> a #product :: Num a => (* :+: f) g a -> a # (Foldable f, Foldable g) => Foldable ((:*:) * f g) Methodsfold :: Monoid m => (* :*: f) g m -> m #foldMap :: Monoid m => (a -> m) -> (* :*: f) g a -> m #foldr :: (a -> b -> b) -> b -> (* :*: f) g a -> b #foldr' :: (a -> b -> b) -> b -> (* :*: f) g a -> b #foldl :: (b -> a -> b) -> b -> (* :*: f) g a -> b #foldl' :: (b -> a -> b) -> b -> (* :*: f) g a -> b #foldr1 :: (a -> a -> a) -> (* :*: f) g a -> a #foldl1 :: (a -> a -> a) -> (* :*: f) g a -> a #toList :: (* :*: f) g a -> [a] #null :: (* :*: f) g a -> Bool #length :: (* :*: f) g a -> Int #elem :: Eq a => a -> (* :*: f) g a -> Bool #maximum :: Ord a => (* :*: f) g a -> a #minimum :: Ord a => (* :*: f) g a -> a #sum :: Num a => (* :*: f) g a -> a #product :: Num a => (* :*: f) g a -> a # Foldable f => Foldable (M1 * i c f) Methodsfold :: Monoid m => M1 * i c f m -> m #foldMap :: Monoid m => (a -> m) -> M1 * i c f a -> m #foldr :: (a -> b -> b) -> b -> M1 * i c f a -> b #foldr' :: (a -> b -> b) -> b -> M1 * i c f a -> b #foldl :: (b -> a -> b) -> b -> M1 * i c f a -> b #foldl' :: (b -> a -> b) -> b -> M1 * i c f a -> b #foldr1 :: (a -> a -> a) -> M1 * i c f a -> a #foldl1 :: (a -> a -> a) -> M1 * i c f a -> a #toList :: M1 * i c f a -> [a] #null :: M1 * i c f a -> Bool #length :: M1 * i c f a -> Int #elem :: Eq a => a -> M1 * i c f a -> Bool #maximum :: Ord a => M1 * i c f a -> a #minimum :: Ord a => M1 * i c f a -> a #sum :: Num a => M1 * i c f a -> a #product :: Num a => M1 * i c f a -> a # (Foldable f, Foldable g) => Foldable ((:.:) * * f g) Methodsfold :: Monoid m => (* :.: *) f g m -> m #foldMap :: Monoid m => (a -> m) -> (* :.: *) f g a -> m #foldr :: (a -> b -> b) -> b -> (* :.: *) f g a -> b #foldr' :: (a -> b -> b) -> b -> (* :.: *) f g a -> b #foldl :: (b -> a -> b) -> b -> (* :.: *) f g a -> b #foldl' :: (b -> a -> b) -> b -> (* :.: *) f g a -> b #foldr1 :: (a -> a -> a) -> (* :.: *) f g a -> a #foldl1 :: (a -> a -> a) -> (* :.: *) f g a -> a #toList :: (* :.: *) f g a -> [a] #null :: (* :.: *) f g a -> Bool #length :: (* :.: *) f g a -> Int #elem :: Eq a => a -> (* :.: *) f g a -> Bool #maximum :: Ord a => (* :.: *) f g a -> a #minimum :: Ord a => (* :.: *) f g a -> a #sum :: Num a => (* :.: *) f g a -> a #product :: Num a => (* :.: *) f g a -> a #

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

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 #

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 () #

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 () #

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 () #

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 #

The sum of a collection of actions, generalizing concat.

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

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 #

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 #

Determines whether any element of the structure satisfies the predicate.

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

Determines whether all elements of the structure satisfy the predicate.

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

notElem is the negation of elem.

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

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.