hask.Data.Foldable
– The Data.Foldable
¶
-
class
hask.Data.Foldable.
Foldable
[source]¶ Data structures that can be folded.
Attributes:
foldr
foldr1
foldl
foldl_
foldl1
toList
null
length
elem
maximum
minimum
sum
product
Minimal complete definition:
foldr
Magic methods:
__iter__
-
hask.Data.Foldable.
foldr
(*args, **kwargs)¶ foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
Right-associative fold of a structure.
-
hask.Data.Foldable.
foldr1
(*args, **kwargs)¶ foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
A variant of foldr that has no base case, and thus may only be applied to non-empty structures.
-
hask.Data.Foldable.
foldl
(*args, **kwargs)¶ foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
Left-associative fold of a structure.
-
hask.Data.Foldable.
foldl_
(*args, **kwargs)¶ foldl_ :: Foldable t => (b -> a -> b) -> b -> t a -> b
Left-associative fold of a structure. but with strict application of the operator.
-
hask.Data.Foldable.
foldl1
(*args, **kwargs)¶ foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
A variant of foldl that has no base case, and thus may only be applied to non-empty structures.
-
hask.Data.Foldable.
toList
(*args, **kwargs)¶ toList :: Foldable t => t a -> [a]
List of elements of a structure, from left to right.
-
hask.Data.Foldable.
length
(*args, **kwargs)¶ length :: Foldable t => t a -> int
Returns the size/length of a finite structure as an int.
-
hask.Data.Foldable.
null
(*args, **kwargs)¶ null :: Foldable t => t a -> Bool
Test whether the structure is empty.
-
hask.Data.Foldable.
elem
(*args, **kwargs)¶ elem :: (Foldable t, Eq a) => a -> t a -> bool
Does the element occur in the structure?
-
hask.Data.Foldable.
maximum
(*args, **kwargs)¶ maximum :: (Foldable t, forall a. Ord a) => t a -> a
The largest element of a non-empty structure.
-
hask.Data.Foldable.
minimum
(*args, **kwargs)¶ minimum :: (Foldable t, forall a. Ord a) => t a -> a
The least element of a non-empty structure.
-
hask.Data.Foldable.
sum
(*args, **kwargs)¶ sum :: (Foldable t, Num a) => t a -> a
The sum function computes the sum of the numbers of a structure.
-
hask.Data.Foldable.
product
(*args, **kwargs)¶ product :: (Foldablet, Num a) => t a -> a
The product function computes the product of the numbers of a structure.
-
hask.Data.Foldable.
foldlM
(*args, **kwargs)¶ foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
Monadic fold over the elements of a structure, associating to the right, i.e. from right to left.
-
hask.Data.Foldable.
foldrM
(*args, **kwargs)¶ 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.
-
hask.Data.Foldable.
traverse_
(*args, **kwargs)¶ 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.
-
hask.Data.Foldable.
for_
(*args, **kwargs)¶ for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
for_
istraverse_
with its arguments flipped. For a version that doesn’t ignore the results see for.
-
hask.Data.Foldable.
sequenceA_
(*args, **kwargs)¶ 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.
-
hask.Data.Foldable.
mapM_
(*args, **kwargs)¶ 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 justtraverse_
, specialized to Monad.
-
hask.Data.Foldable.
forM_
(*args, **kwargs)¶ forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
forM_
ismapM_
with its arguments flipped. For a version that doesn’t ignore the results see forM.As of base 4.8.0.0,
forM_
is justfor_
, specialized to Monad.
-
hask.Data.Foldable.
sequence_
(*args, **kwargs)¶ 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 justsequenceA_
, specialized to Monad.
-
hask.Data.Foldable.
concat
(*args, **kwargs)¶ concat :: Foldable t => t [a] -> [a]
The concatenation of all the elements of a container of lists.
-
hask.Data.Foldable.
concatMap
(*args, **kwargs)¶ concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
Map a function over all the elements of a container and concatenate the resulting lists.
-
hask.Data.Foldable.
and_
(*args, **kwargs)¶ 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.
-
hask.Data.Foldable.
or_
(*args, **kwargs)¶ 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.
-
hask.Data.Foldable.
any_
(*args, **kwargs)¶ any :: Foldable t => (a -> bool) -> t a -> bool
Determines whether any element of the structure satisfies the predicate.
-
hask.Data.Foldable.
all_
(*args, **kwargs)¶ all :: Foldable t => (a -> bool) -> t a -> bool
Determines whether all elements of the structure satisfy the predicate.
-
hask.Data.Foldable.
maximumBy_
(*args, **kwargs)¶ maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
The largest element of a non-empty structure with respect to the given comparison function.
-
hask.Data.Foldable.
minimumBy_
(*args, **kwargs)¶ minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
The least element of a non-empty structure with respect to the given comparison function.
-
hask.Data.Foldable.
notElem
(*args, **kwargs)¶ notElem :: (Foldable t, Eq a) => a -> t a -> bool
notElem is the negation of elem.
-
hask.Data.Foldable.
find
(*args, **kwargs)¶ 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.