relude-0.2.0: Custom prelude from Kowainik

Copyright (c) 2018 Kowainik MIT Kowainik Safe Haskell2010

Relude.Foldable.Reexport

Description

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

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

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.

length :: t a -> Int #

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.

Instances
 Foldable [] Since: base-2.1 Instance detailsDefined in Data.Foldable 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: base-2.1 Instance detailsDefined in Data.Foldable 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 # Instance detailsDefined in Data.Foldable 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 # Instance detailsDefined in Data.Complex Methodsfold :: Monoid m => Complex m -> m #foldMap :: Monoid m => (a -> m) -> Complex a -> m #foldr :: (a -> b -> b) -> b -> Complex a -> b #foldr' :: (a -> b -> b) -> b -> Complex a -> b #foldl :: (b -> a -> b) -> b -> Complex a -> b #foldl' :: (b -> a -> b) -> b -> Complex a -> b #foldr1 :: (a -> a -> a) -> Complex a -> a #foldl1 :: (a -> a -> a) -> Complex a -> a #toList :: Complex a -> [a] #null :: Complex a -> Bool #length :: Complex a -> Int #elem :: Eq a => a -> Complex a -> Bool #maximum :: Ord a => Complex a -> a #minimum :: Ord a => Complex a -> a #sum :: Num a => Complex a -> a #product :: Num a => Complex a -> a # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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 # Instance detailsDefined in Control.Applicative 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: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methodsfold :: Monoid m => Identity m -> m #foldMap :: Monoid m => (a -> m) -> Identity a -> m #foldr :: (a -> b -> b) -> b -> Identity a -> b #foldr' :: (a -> b -> b) -> b -> Identity a -> b #foldl :: (b -> a -> b) -> b -> Identity a -> b #foldl' :: (b -> a -> b) -> b -> Identity a -> b #foldr1 :: (a -> a -> a) -> Identity a -> a #foldl1 :: (a -> a -> a) -> Identity a -> a #toList :: Identity a -> [a] #null :: Identity a -> Bool #length :: Identity a -> Int #elem :: Eq a => a -> Identity a -> Bool #maximum :: Ord a => Identity a -> a #minimum :: Ord a => Identity a -> a #sum :: Num a => Identity a -> a #product :: Num a => Identity a -> a # Since: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.9.0.0 Instance detailsDefined in Data.Foldable 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 # Instance detailsDefined in Data.IntMap.Internal Methodsfold :: Monoid m => IntMap m -> m #foldMap :: Monoid m => (a -> m) -> IntMap a -> m #foldr :: (a -> b -> b) -> b -> IntMap a -> b #foldr' :: (a -> b -> b) -> b -> IntMap a -> b #foldl :: (b -> a -> b) -> b -> IntMap a -> b #foldl' :: (b -> a -> b) -> b -> IntMap a -> b #foldr1 :: (a -> a -> a) -> IntMap a -> a #foldl1 :: (a -> a -> a) -> IntMap a -> a #toList :: IntMap a -> [a] #null :: IntMap a -> Bool #length :: IntMap a -> Int #elem :: Eq a => a -> IntMap a -> Bool #maximum :: Ord a => IntMap a -> a #minimum :: Ord a => IntMap a -> a #sum :: Num a => IntMap a -> a #product :: Num a => IntMap a -> a # Instance detailsDefined in Data.Tree Methodsfold :: Monoid m => Tree m -> m #foldMap :: Monoid m => (a -> m) -> Tree a -> m #foldr :: (a -> b -> b) -> b -> Tree a -> b #foldr' :: (a -> b -> b) -> b -> Tree a -> b #foldl :: (b -> a -> b) -> b -> Tree a -> b #foldl' :: (b -> a -> b) -> b -> Tree a -> b #foldr1 :: (a -> a -> a) -> Tree a -> a #foldl1 :: (a -> a -> a) -> Tree a -> a #toList :: Tree a -> [a] #null :: Tree a -> Bool #length :: Tree a -> Int #elem :: Eq a => a -> Tree a -> Bool #maximum :: Ord a => Tree a -> a #minimum :: Ord a => Tree a -> a #sum :: Num a => Tree a -> a #product :: Num a => Tree a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => Seq m -> m #foldMap :: Monoid m => (a -> m) -> Seq a -> m #foldr :: (a -> b -> b) -> b -> Seq a -> b #foldr' :: (a -> b -> b) -> b -> Seq a -> b #foldl :: (b -> a -> b) -> b -> Seq a -> b #foldl' :: (b -> a -> b) -> b -> Seq a -> b #foldr1 :: (a -> a -> a) -> Seq a -> a #foldl1 :: (a -> a -> a) -> Seq a -> a #toList :: Seq a -> [a] #null :: Seq a -> Bool #length :: Seq a -> Int #elem :: Eq a => a -> Seq a -> Bool #maximum :: Ord a => Seq a -> a #minimum :: Ord a => Seq a -> a #sum :: Num a => Seq a -> a #product :: Num a => Seq a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => FingerTree m -> m #foldMap :: Monoid m => (a -> m) -> FingerTree a -> m #foldr :: (a -> b -> b) -> b -> FingerTree a -> b #foldr' :: (a -> b -> b) -> b -> FingerTree a -> b #foldl :: (b -> a -> b) -> b -> FingerTree a -> b #foldl' :: (b -> a -> b) -> b -> FingerTree a -> b #foldr1 :: (a -> a -> a) -> FingerTree a -> a #foldl1 :: (a -> a -> a) -> FingerTree a -> a #toList :: FingerTree a -> [a] #null :: FingerTree a -> Bool #length :: FingerTree a -> Int #elem :: Eq a => a -> FingerTree a -> Bool #maximum :: Ord a => FingerTree a -> a #minimum :: Ord a => FingerTree a -> a #sum :: Num a => FingerTree a -> a #product :: Num a => FingerTree a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => Digit m -> m #foldMap :: Monoid m => (a -> m) -> Digit a -> m #foldr :: (a -> b -> b) -> b -> Digit a -> b #foldr' :: (a -> b -> b) -> b -> Digit a -> b #foldl :: (b -> a -> b) -> b -> Digit a -> b #foldl' :: (b -> a -> b) -> b -> Digit a -> b #foldr1 :: (a -> a -> a) -> Digit a -> a #foldl1 :: (a -> a -> a) -> Digit a -> a #toList :: Digit a -> [a] #null :: Digit a -> Bool #length :: Digit a -> Int #elem :: Eq a => a -> Digit a -> Bool #maximum :: Ord a => Digit a -> a #minimum :: Ord a => Digit a -> a #sum :: Num a => Digit a -> a #product :: Num a => Digit a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => Node m -> m #foldMap :: Monoid m => (a -> m) -> Node a -> m #foldr :: (a -> b -> b) -> b -> Node a -> b #foldr' :: (a -> b -> b) -> b -> Node a -> b #foldl :: (b -> a -> b) -> b -> Node a -> b #foldl' :: (b -> a -> b) -> b -> Node a -> b #foldr1 :: (a -> a -> a) -> Node a -> a #foldl1 :: (a -> a -> a) -> Node a -> a #toList :: Node a -> [a] #null :: Node a -> Bool #length :: Node a -> Int #elem :: Eq a => a -> Node a -> Bool #maximum :: Ord a => Node a -> a #minimum :: Ord a => Node a -> a #sum :: Num a => Node a -> a #product :: Num a => Node a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => Elem m -> m #foldMap :: Monoid m => (a -> m) -> Elem a -> m #foldr :: (a -> b -> b) -> b -> Elem a -> b #foldr' :: (a -> b -> b) -> b -> Elem a -> b #foldl :: (b -> a -> b) -> b -> Elem a -> b #foldl' :: (b -> a -> b) -> b -> Elem a -> b #foldr1 :: (a -> a -> a) -> Elem a -> a #foldl1 :: (a -> a -> a) -> Elem a -> a #toList :: Elem a -> [a] #null :: Elem a -> Bool #length :: Elem a -> Int #elem :: Eq a => a -> Elem a -> Bool #maximum :: Ord a => Elem a -> a #minimum :: Ord a => Elem a -> a #sum :: Num a => Elem a -> a #product :: Num a => Elem a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => ViewL m -> m #foldMap :: Monoid m => (a -> m) -> ViewL a -> m #foldr :: (a -> b -> b) -> b -> ViewL a -> b #foldr' :: (a -> b -> b) -> b -> ViewL a -> b #foldl :: (b -> a -> b) -> b -> ViewL a -> b #foldl' :: (b -> a -> b) -> b -> ViewL a -> b #foldr1 :: (a -> a -> a) -> ViewL a -> a #foldl1 :: (a -> a -> a) -> ViewL a -> a #toList :: ViewL a -> [a] #null :: ViewL a -> Bool #length :: ViewL a -> Int #elem :: Eq a => a -> ViewL a -> Bool #maximum :: Ord a => ViewL a -> a #minimum :: Ord a => ViewL a -> a #sum :: Num a => ViewL a -> a #product :: Num a => ViewL a -> a # Instance detailsDefined in Data.Sequence.Internal Methodsfold :: Monoid m => ViewR m -> m #foldMap :: Monoid m => (a -> m) -> ViewR a -> m #foldr :: (a -> b -> b) -> b -> ViewR a -> b #foldr' :: (a -> b -> b) -> b -> ViewR a -> b #foldl :: (b -> a -> b) -> b -> ViewR a -> b #foldl' :: (b -> a -> b) -> b -> ViewR a -> b #foldr1 :: (a -> a -> a) -> ViewR a -> a #foldl1 :: (a -> a -> a) -> ViewR a -> a #toList :: ViewR a -> [a] #null :: ViewR a -> Bool #length :: ViewR a -> Int #elem :: Eq a => a -> ViewR a -> Bool #maximum :: Ord a => ViewR a -> a #minimum :: Ord a => ViewR a -> a #sum :: Num a => ViewR a -> a #product :: Num a => ViewR a -> a # Instance detailsDefined in Data.Set.Internal Methodsfold :: Monoid m => Set m -> m #foldMap :: Monoid m => (a -> m) -> Set a -> m #foldr :: (a -> b -> b) -> b -> Set a -> b #foldr' :: (a -> b -> b) -> b -> Set a -> b #foldl :: (b -> a -> b) -> b -> Set a -> b #foldl' :: (b -> a -> b) -> b -> Set a -> b #foldr1 :: (a -> a -> a) -> Set a -> a #foldl1 :: (a -> a -> a) -> Set a -> a #toList :: Set a -> [a] #null :: Set a -> Bool #length :: Set a -> Int #elem :: Eq a => a -> Set a -> Bool #maximum :: Ord a => Set a -> a #minimum :: Ord a => Set a -> a #sum :: Num a => Set a -> a #product :: Num a => Set a -> a # Instance detailsDefined in Data.Hashable.Class Methodsfold :: Monoid m => Hashed m -> m #foldMap :: Monoid m => (a -> m) -> Hashed a -> m #foldr :: (a -> b -> b) -> b -> Hashed a -> b #foldr' :: (a -> b -> b) -> b -> Hashed a -> b #foldl :: (b -> a -> b) -> b -> Hashed a -> b #foldl' :: (b -> a -> b) -> b -> Hashed a -> b #foldr1 :: (a -> a -> a) -> Hashed a -> a #foldl1 :: (a -> a -> a) -> Hashed a -> a #toList :: Hashed a -> [a] #null :: Hashed a -> Bool #length :: Hashed a -> Int #elem :: Eq a => a -> Hashed a -> Bool #maximum :: Ord a => Hashed a -> a #minimum :: Ord a => Hashed a -> a #sum :: Num a => Hashed a -> a #product :: Num a => Hashed a -> a # Instance detailsDefined in Data.HashSet Methodsfold :: Monoid m => HashSet m -> m #foldMap :: Monoid m => (a -> m) -> HashSet a -> m #foldr :: (a -> b -> b) -> b -> HashSet a -> b #foldr' :: (a -> b -> b) -> b -> HashSet a -> b #foldl :: (b -> a -> b) -> b -> HashSet a -> b #foldl' :: (b -> a -> b) -> b -> HashSet a -> b #foldr1 :: (a -> a -> a) -> HashSet a -> a #foldl1 :: (a -> a -> a) -> HashSet a -> a #toList :: HashSet a -> [a] #null :: HashSet a -> Bool #length :: HashSet a -> Int #elem :: Eq a => a -> HashSet a -> Bool #maximum :: Ord a => HashSet a -> a #minimum :: Ord a => HashSet a -> a #sum :: Num a => HashSet a -> a #product :: Num a => HashSet a -> a # Since: base-4.7.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => Either a m -> m #foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m #foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b #foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b #foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b #foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b #foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 #foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 #toList :: Either a a0 -> [a0] #null :: Either a a0 -> Bool #length :: Either a a0 -> Int #elem :: Eq a0 => a0 -> Either a a0 -> Bool #maximum :: Ord a0 => Either a a0 -> a0 #minimum :: Ord a0 => Either a a0 -> a0 #sum :: Num a0 => Either a a0 -> a0 #product :: Num a0 => Either a a0 -> a0 # Foldable (V1 :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (U1 :: * -> *) Since: base-4.9.0.0 Instance detailsDefined in Data.Foldable 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: base-4.7.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => (a, m) -> m #foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m #foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b #foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b #foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b #foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b #foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 #foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 #toList :: (a, a0) -> [a0] #null :: (a, a0) -> Bool #length :: (a, a0) -> Int #elem :: Eq a0 => a0 -> (a, a0) -> Bool #maximum :: Ord a0 => (a, a0) -> a0 #minimum :: Ord a0 => (a, a0) -> a0 #sum :: Num a0 => (a, a0) -> a0 #product :: Num a0 => (a, a0) -> a0 # Since: base-4.8.0.0 Instance detailsDefined in Data.Foldable 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: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfold :: Monoid m => Arg a m -> m #foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m #foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b #foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b #foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b #foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b #foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 #foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 #toList :: Arg a a0 -> [a0] #null :: Arg a a0 -> Bool #length :: Arg a a0 -> Int #elem :: Eq a0 => a0 -> Arg a a0 -> Bool #maximum :: Ord a0 => Arg a a0 -> a0 #minimum :: Ord a0 => Arg a a0 -> a0 #sum :: Num a0 => Arg a a0 -> a0 #product :: Num a0 => Arg a a0 -> a0 # Foldable (Proxy :: * -> *) Since: base-4.7.0.0 Instance detailsDefined in Data.Foldable 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 (Map k) Instance detailsDefined in Data.Map.Internal Methodsfold :: Monoid m => Map k m -> m #foldMap :: Monoid m => (a -> m) -> Map k a -> m #foldr :: (a -> b -> b) -> b -> Map k a -> b #foldr' :: (a -> b -> b) -> b -> Map k a -> b #foldl :: (b -> a -> b) -> b -> Map k a -> b #foldl' :: (b -> a -> b) -> b -> Map k a -> b #foldr1 :: (a -> a -> a) -> Map k a -> a #foldl1 :: (a -> a -> a) -> Map k a -> a #toList :: Map k a -> [a] #null :: Map k a -> Bool #length :: Map k a -> Int #elem :: Eq a => a -> Map k a -> Bool #maximum :: Ord a => Map k a -> a #minimum :: Ord a => Map k a -> a #sum :: Num a => Map k a -> a #product :: Num a => Map k a -> a # Foldable f => Foldable (MaybeT f) Instance detailsDefined in Control.Monad.Trans.Maybe Methodsfold :: Monoid m => MaybeT f m -> m #foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m #foldr :: (a -> b -> b) -> b -> MaybeT f a -> b #foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b #foldl :: (b -> a -> b) -> b -> MaybeT f a -> b #foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b #foldr1 :: (a -> a -> a) -> MaybeT f a -> a #foldl1 :: (a -> a -> a) -> MaybeT f a -> a #toList :: MaybeT f a -> [a] #null :: MaybeT f a -> Bool #length :: MaybeT f a -> Int #elem :: Eq a => a -> MaybeT f a -> Bool #maximum :: Ord a => MaybeT f a -> a #minimum :: Ord a => MaybeT f a -> a #sum :: Num a => MaybeT f a -> a #product :: Num a => MaybeT f a -> a # Instance detailsDefined in Data.HashMap.Base Methodsfold :: Monoid m => HashMap k m -> m #foldMap :: Monoid m => (a -> m) -> HashMap k a -> m #foldr :: (a -> b -> b) -> b -> HashMap k a -> b #foldr' :: (a -> b -> b) -> b -> HashMap k a -> b #foldl :: (b -> a -> b) -> b -> HashMap k a -> b #foldl' :: (b -> a -> b) -> b -> HashMap k a -> b #foldr1 :: (a -> a -> a) -> HashMap k a -> a #foldl1 :: (a -> a -> a) -> HashMap k a -> a #toList :: HashMap k a -> [a] #null :: HashMap k a -> Bool #length :: HashMap k a -> Int #elem :: Eq a => a -> HashMap k a -> Bool #maximum :: Ord a => HashMap k a -> a #minimum :: Ord a => HashMap k a -> a #sum :: Num a => HashMap k a -> a #product :: Num a => HashMap k a -> a # Foldable f => Foldable (Rec1 f) Instance detailsDefined in Data.Foldable 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 # Foldable (URec Char :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (URec Double :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (URec Float :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (URec Int :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (URec Word :: * -> *) Instance detailsDefined in Data.Foldable 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 ()) :: * -> *) Instance detailsDefined in Data.Foldable 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 # Foldable (Const m :: * -> *) Since: base-4.7.0.0 Instance detailsDefined in Data.Functor.Const Methodsfold :: Monoid m0 => Const m m0 -> m0 #foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 #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 f => Foldable (IdentityT f) Instance detailsDefined in Control.Monad.Trans.Identity Methodsfold :: Monoid m => IdentityT f m -> m #foldMap :: Monoid m => (a -> m) -> IdentityT f a -> m #foldr :: (a -> b -> b) -> b -> IdentityT f a -> b #foldr' :: (a -> b -> b) -> b -> IdentityT f a -> b #foldl :: (b -> a -> b) -> b -> IdentityT f a -> b #foldl' :: (b -> a -> b) -> b -> IdentityT f a -> b #foldr1 :: (a -> a -> a) -> IdentityT f a -> a #foldl1 :: (a -> a -> a) -> IdentityT f a -> a #toList :: IdentityT f a -> [a] #null :: IdentityT f a -> Bool #length :: IdentityT f a -> Int #elem :: Eq a => a -> IdentityT f a -> Bool #maximum :: Ord a => IdentityT f a -> a #minimum :: Ord a => IdentityT f a -> a #sum :: Num a => IdentityT f a -> a #product :: Num a => IdentityT f a -> a # Foldable f => Foldable (ErrorT e f) Instance detailsDefined in Control.Monad.Trans.Error Methodsfold :: Monoid m => ErrorT e f m -> m #foldMap :: Monoid m => (a -> m) -> ErrorT e f a -> m #foldr :: (a -> b -> b) -> b -> ErrorT e f a -> b #foldr' :: (a -> b -> b) -> b -> ErrorT e f a -> b #foldl :: (b -> a -> b) -> b -> ErrorT e f a -> b #foldl' :: (b -> a -> b) -> b -> ErrorT e f a -> b #foldr1 :: (a -> a -> a) -> ErrorT e f a -> a #foldl1 :: (a -> a -> a) -> ErrorT e f a -> a #toList :: ErrorT e f a -> [a] #null :: ErrorT e f a -> Bool #length :: ErrorT e f a -> Int #elem :: Eq a => a -> ErrorT e f a -> Bool #maximum :: Ord a => ErrorT e f a -> a #minimum :: Ord a => ErrorT e f a -> a #sum :: Num a => ErrorT e f a -> a #product :: Num a => ErrorT e f a -> a # Foldable f => Foldable (ExceptT e f) Instance detailsDefined in Control.Monad.Trans.Except Methodsfold :: Monoid m => ExceptT e f m -> m #foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m #foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b #foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b #foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b #foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b #foldr1 :: (a -> a -> a) -> ExceptT e f a -> a #foldl1 :: (a -> a -> a) -> ExceptT e f a -> a #toList :: ExceptT e f a -> [a] #null :: ExceptT e f a -> Bool #length :: ExceptT e f a -> Int #elem :: Eq a => a -> ExceptT e f a -> Bool #maximum :: Ord a => ExceptT e f a -> a #minimum :: Ord a => ExceptT e f a -> a #sum :: Num a => ExceptT e f a -> a #product :: Num a => ExceptT e f a -> a # Foldable (K1 i c :: * -> *) Instance detailsDefined in Data.Foldable 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) Instance detailsDefined in Data.Foldable 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) Instance detailsDefined in Data.Foldable 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 (Product f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodsfold :: Monoid m => Product f g m -> m #foldMap :: Monoid m => (a -> m) -> Product f g a -> m #foldr :: (a -> b -> b) -> b -> Product f g a -> b #foldr' :: (a -> b -> b) -> b -> Product f g a -> b #foldl :: (b -> a -> b) -> b -> Product f g a -> b #foldl' :: (b -> a -> b) -> b -> Product f g a -> b #foldr1 :: (a -> a -> a) -> Product f g a -> a #foldl1 :: (a -> a -> a) -> Product f g a -> a #toList :: Product f g a -> [a] #null :: Product f g a -> Bool #length :: Product f g a -> Int #elem :: Eq a => a -> Product f g a -> Bool #maximum :: Ord a => Product f g a -> a #minimum :: Ord a => Product f g a -> a #sum :: Num a => Product f g a -> a #product :: Num a => Product f g a -> a # (Foldable f, Foldable g) => Foldable (Sum f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Sum Methodsfold :: Monoid m => Sum f g m -> m #foldMap :: Monoid m => (a -> m) -> Sum f g a -> m #foldr :: (a -> b -> b) -> b -> Sum f g a -> b #foldr' :: (a -> b -> b) -> b -> Sum f g a -> b #foldl :: (b -> a -> b) -> b -> Sum f g a -> b #foldl' :: (b -> a -> b) -> b -> Sum f g a -> b #foldr1 :: (a -> a -> a) -> Sum f g a -> a #foldl1 :: (a -> a -> a) -> Sum f g a -> a #toList :: Sum f g a -> [a] #null :: Sum f g a -> Bool #length :: Sum f g a -> Int #elem :: Eq a => a -> Sum f g a -> Bool #maximum :: Ord a => Sum f g a -> a #minimum :: Ord a => Sum f g a -> a #sum :: Num a => Sum f g a -> a #product :: Num a => Sum f g a -> a # Foldable f => Foldable (M1 i c f) Instance detailsDefined in Data.Foldable 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) Instance detailsDefined in Data.Foldable 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 (Compose f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methodsfold :: Monoid m => Compose f g m -> m #foldMap :: Monoid m => (a -> m) -> Compose f g a -> m #foldr :: (a -> b -> b) -> b -> Compose f g a -> b #foldr' :: (a -> b -> b) -> b -> Compose f g a -> b #foldl :: (b -> a -> b) -> b -> Compose f g a -> b #foldl' :: (b -> a -> b) -> b -> Compose f g a -> b #foldr1 :: (a -> a -> a) -> Compose f g a -> a #foldl1 :: (a -> a -> a) -> Compose f g a -> a #toList :: Compose f g a -> [a] #null :: Compose f g a -> Bool #length :: Compose f g a -> Int #elem :: Eq a => a -> Compose f g a -> Bool #maximum :: Ord a => Compose f g a -> a #minimum :: Ord a => Compose f g a -> a #sum :: Num a => Compose f g a -> a #product :: Num a => Compose f g a -> a #

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.

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

Determines whether all elements of the structure satisfy the predicate.

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

Determines whether any element of the structure satisfies the predicate.

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.

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.

concatMap :: Foldable t => (a -> [b]) -> t a -> [b] #

Map a function over all the elements of a container and concatenate the resulting lists.

concat :: Foldable t => t [a] -> [a] #

The concatenation of all the elements of a container of lists.

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

The sum of a collection of actions, generalizing concat.

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

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

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.

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.

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

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.

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

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.

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


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.

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.

class (Functor t, Foldable t) => Traversable (t :: * -> *) where #

Functors representing data structures that can be traversed from left to right.

A definition of traverse must satisfy the following laws:

naturality
t . traverse f = traverse (t . f) for every applicative transformation t
identity
traverse Identity = Identity
composition
traverse (Compose . fmap g . f) = Compose . fmap (traverse g) . traverse f

A definition of sequenceA must satisfy the following laws:

naturality
t . sequenceA = sequenceA . fmap t for every applicative transformation t
identity
sequenceA . fmap Identity = Identity
composition
sequenceA . fmap Compose = Compose . fmap sequenceA . sequenceA

where an applicative transformation is a function

t :: (Applicative f, Applicative g) => f a -> g a

preserving the Applicative operations, i.e.

• t (pure x) = pure x
• t (x <*> y) = t x <*> t y

and the identity functor Identity and composition of functors Compose are defined as

  newtype Identity a = Identity a

instance Functor Identity where
fmap f (Identity x) = Identity (f x)

instance Applicative Identity where
pure x = Identity x
Identity f <*> Identity x = Identity (f x)

newtype Compose f g a = Compose (f (g a))

instance (Functor f, Functor g) => Functor (Compose f g) where
fmap f (Compose x) = Compose (fmap (fmap f) x)

instance (Applicative f, Applicative g) => Applicative (Compose f g) where
pure x = Compose (pure (pure x))
Compose f <*> Compose x = Compose ((<*>) <$> f <*> x) (The naturality law is implied by parametricity.) Instances are similar to Functor, e.g. given a data type data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) a suitable instance would be instance Traversable Tree where traverse f Empty = pure Empty traverse f (Leaf x) = Leaf <$> f x
traverse f (Node l k r) = Node <\$> traverse f l <*> f k <*> traverse f r

This is suitable even for abstract types, as the laws for <*> imply a form of associativity.

The superclass instances should satisfy the following:

• In the Functor instance, fmap should be equivalent to traversal with the identity applicative functor (fmapDefault).
• In the Foldable instance, foldMap should be equivalent to traversal with a constant applicative functor (foldMapDefault).

Minimal complete definition

Methods

traverse :: Applicative f => (a -> f b) -> t a -> f (t b) #

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see traverse_.

sequenceA :: Applicative f => t (f a) -> f (t a) #

Evaluate each action in the structure from left to right, and and collect the results. For a version that ignores the results see sequenceA_.

mapM :: Monad m => (a -> m b) -> t a -> m (t b) #

Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see mapM_.

sequence :: Monad m => t (m a) -> m (t a) #

Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see sequence_.

Instances
The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.
The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.
forM is mapM with its arguments flipped. For a version that ignores the results see forM_.