DA.Foldable
Class of data structures that can be folded to a summary value. It’s a good idea to import this module qualified to avoid clashes with functions defined inPrelude. Ie.:
Module Snapshot
Lifecycle
Stable.
Notices
Status:
active
Introduced in: 3.4.9
Removed in: -
Warnings: 0
Deprecations: 0
Deprecated since: -Typeclasses
class Foldable t
Class of data structures that can be folded to a summary value.
Methods:
fold:Monoidm=>tm->mCombine the elements of a structure using a monoid.foldMap:Monoidm=> (a->m) ->ta->mCombine the elements of a structure using a monoid.foldr: (a->b->b) ->b->ta->bRight-associative fold of a structure.foldl: (b->a->b) ->b->ta->bLeft-associative fold of a structure.foldr1: (a->a->a) ->ta->aA variant of foldr that has no base case, and thus should only be applied to non-empty structures.foldl1: (a->a->a) ->ta->aA variant of foldl that has no base case, and thus should only be applied to non-empty structures.toList:ta-> [a] List of elements of a structure, from left to right.null:ta->BoolTest 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:ta->IntReturns the size/length of a finite structure as anInt. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.elem:Eqa=>a->ta->BoolDoes the element occur in the structure?sum:Additivea=>ta->aThe sum function computes the sum of the numbers of a structure.product:Multiplicativea=>ta->aThe product function computes the product of the numbers of a structure.minimum:Orda=>ta->aThe least element of a non-empty structure.maximum:Orda=>ta->aThe largest element of a non-empty structure.
- instance
Ordk=>Foldable(Mapk) - instance
FoldableTextMap - instance
FoldableOptional - instance
FoldableNonEmpty - instance
FoldableSet - instance
Foldable(Validationerr) - instance
Foldable(Eithera) - instance
Foldable[] - instance
Foldablea
Functions
mapA_
mapA_ : (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 ‘DA.Traversable.mapA’.
forA_
forA_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
‘for_’ is ‘mapA_’ with its arguments flipped. For a version
that doesn’t ignore the results see ‘DA.Traversable.forA’.
forM_
forM_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
sequence_
sequence_ : (Foldable t, Action m) => t (m a) -> m ()
Evaluate each action in the structure from left to right,
and ignore the results. For a version that doesn’t ignore the
results see ‘DA.Traversable.sequence’.
concat
concat : Foldable t => t [a] -> [a]
The concatenation of all the elements of a container of lists.
and
and : Foldable t => t Bool -> Bool
and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.
or
or : Foldable t => t Bool -> Bool
or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.
any
any : Foldable t => (a -> Bool) -> t a -> Bool
Determines whether any element of the structure satisfies the predicate.
all
all : Foldable t => (a -> Bool) -> t a -> Bool
Determines whether all elements of the structure satisfy the predicate.