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 |
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 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)
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 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
List of elements of a structure, from left to right.
Since: base-4.8.0.0
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
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
Foldable [] | Since: base-2.1 |
Defined in Data.Foldable Methodsfold :: 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 elem :: Eq a => a -> [a] -> Bool Source maximum :: Ord a => [a] -> a Source minimum :: Ord a => [a] -> a Source | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable Par1 | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 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 | |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable Down | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: 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 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 | |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable Sum | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 elem :: Eq a => a -> Sum a -> Bool Source maximum :: Ord a => Sum a -> a Source minimum :: Ord a => Sum a -> a Source | |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 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 | |
Foldable Last | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 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 | |
Foldable First | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity Methodsfold :: 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 | |
Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative Methodsfold :: 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 | |
Foldable Option | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 | |
Foldable Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 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 | |
Foldable First | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 | |
Foldable Max | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 elem :: Eq a => a -> Max a -> Bool Source maximum :: Ord a => Max a -> a Source minimum :: Ord a => Max a -> a Source | |
Foldable Min | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 elem :: Eq a => a -> Min a -> Bool Source maximum :: Ord a => Min a -> a Source minimum :: Ord a => Min a -> a Source | |
Foldable Complex | Since: base-4.9.0.0 |
Defined in Data.Complex Methodsfold :: 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 | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable (V1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 elem :: Eq a => a -> V1 a -> Bool Source maximum :: Ord a => V1 a -> a Source minimum :: Ord a => V1 a -> a Source | |
Foldable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 elem :: Eq a => a -> U1 a -> Bool Source maximum :: Ord a => U1 a -> a Source minimum :: Ord a => U1 a -> a Source | |
Foldable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable (Array i) | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable (Arg a) | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: 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 | |
Foldable f => Foldable (Rec1 f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec Char m -> m Source foldMap :: Monoid m => (a -> m) -> URec Char a -> m Source foldMap' :: Monoid m => (a -> m) -> URec Char a -> m Source foldr :: (a -> b -> b) -> b -> URec Char a -> b Source foldr' :: (a -> b -> b) -> b -> URec Char a -> b Source foldl :: (b -> a -> b) -> b -> URec Char a -> b Source foldl' :: (b -> a -> b) -> b -> URec Char a -> b Source foldr1 :: (a -> a -> a) -> URec Char a -> a Source foldl1 :: (a -> a -> a) -> URec Char a -> a Source toList :: URec Char a -> [a] Source null :: URec Char a -> Bool Source length :: URec Char a -> Int Source elem :: Eq a => a -> URec Char a -> Bool Source maximum :: Ord a => URec Char a -> a Source minimum :: Ord a => URec Char a -> a Source | |
Foldable (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec Double m -> m Source foldMap :: Monoid m => (a -> m) -> URec Double a -> m Source foldMap' :: Monoid m => (a -> m) -> URec Double a -> m Source foldr :: (a -> b -> b) -> b -> URec Double a -> b Source foldr' :: (a -> b -> b) -> b -> URec Double a -> b Source foldl :: (b -> a -> b) -> b -> URec Double a -> b Source foldl' :: (b -> a -> b) -> b -> URec Double a -> b Source foldr1 :: (a -> a -> a) -> URec Double a -> a Source foldl1 :: (a -> a -> a) -> URec Double a -> a Source toList :: URec Double a -> [a] Source null :: URec Double a -> Bool Source length :: URec Double a -> Int Source elem :: Eq a => a -> URec Double a -> Bool Source maximum :: Ord a => URec Double a -> a Source minimum :: Ord a => URec Double a -> a Source | |
Foldable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec Float m -> m Source foldMap :: Monoid m => (a -> m) -> URec Float a -> m Source foldMap' :: Monoid m => (a -> m) -> URec Float a -> m Source foldr :: (a -> b -> b) -> b -> URec Float a -> b Source foldr' :: (a -> b -> b) -> b -> URec Float a -> b Source foldl :: (b -> a -> b) -> b -> URec Float a -> b Source foldl' :: (b -> a -> b) -> b -> URec Float a -> b Source foldr1 :: (a -> a -> a) -> URec Float a -> a Source foldl1 :: (a -> a -> a) -> URec Float a -> a Source toList :: URec Float a -> [a] Source null :: URec Float a -> Bool Source length :: URec Float a -> Int Source elem :: Eq a => a -> URec Float a -> Bool Source maximum :: Ord a => URec Float a -> a Source minimum :: Ord a => URec Float a -> a Source | |
Foldable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec Int m -> m Source foldMap :: Monoid m => (a -> m) -> URec Int a -> m Source foldMap' :: Monoid m => (a -> m) -> URec Int a -> m Source foldr :: (a -> b -> b) -> b -> URec Int a -> b Source foldr' :: (a -> b -> b) -> b -> URec Int a -> b Source foldl :: (b -> a -> b) -> b -> URec Int a -> b Source foldl' :: (b -> a -> b) -> b -> URec Int a -> b Source foldr1 :: (a -> a -> a) -> URec Int a -> a Source foldl1 :: (a -> a -> a) -> URec Int a -> a Source toList :: URec Int a -> [a] Source null :: URec Int a -> Bool Source length :: URec Int a -> Int Source elem :: Eq a => a -> URec Int a -> Bool Source maximum :: Ord a => URec Int a -> a Source minimum :: Ord a => URec Int a -> a Source | |
Foldable (URec Word :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec Word m -> m Source foldMap :: Monoid m => (a -> m) -> URec Word a -> m Source foldMap' :: Monoid m => (a -> m) -> URec Word a -> m Source foldr :: (a -> b -> b) -> b -> URec Word a -> b Source foldr' :: (a -> b -> b) -> b -> URec Word a -> b Source foldl :: (b -> a -> b) -> b -> URec Word a -> b Source foldl' :: (b -> a -> b) -> b -> URec Word a -> b Source foldr1 :: (a -> a -> a) -> URec Word a -> a Source foldl1 :: (a -> a -> a) -> URec Word a -> a Source toList :: URec Word a -> [a] Source null :: URec Word a -> Bool Source length :: URec Word a -> Int Source elem :: Eq a => a -> URec Word a -> Bool Source maximum :: Ord a => URec Word a -> a Source minimum :: Ord a => URec Word a -> a Source | |
Foldable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => URec (Ptr ()) m -> m Source foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m Source foldMap' :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m Source foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source toList :: URec (Ptr ()) a -> [a] Source null :: URec (Ptr ()) a -> Bool Source length :: URec (Ptr ()) a -> Int Source elem :: Eq a => a -> URec (Ptr ()) a -> Bool Source maximum :: Ord a => URec (Ptr ()) a -> a Source minimum :: Ord a => URec (Ptr ()) a -> a Source | |
Foldable f => Foldable (Alt f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
Foldable f => Foldable (Ap f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: 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 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 | |
Foldable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methodsfold :: 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 | |
Foldable (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methodsfold :: 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 | |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: 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 | |
(Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methodsfold :: 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 |
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.
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"
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
.
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.
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.8.3/docs/html/libraries/base-4.13.0.0/Data-Foldable.html