module Data.Foldable
base Data.Foldable
Class of data structures that can be folded to a summary value. Many of these functions generalize Prelude, Control.Monad and Data.List functions of the same names from lists to any Foldable functor. To avoid ambiguity, either import those modules hiding these names or qualify uses of these function names with an alias for this module.
class Foldable t
base Data.Foldable
Data structures that can be folded. Minimal complete definition: foldMap or foldr. 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 > 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 > 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
package mono-foldable
Like Data.Foldable, but works with ByteStrings too Version
seqFoldable :: Foldable t => Strategy a -> Strategy (t a)
parallel Control.Seq
Evaluate the elements of a foldable data structure according to the given strategy.
package unfoldable
Just as there's a Foldable class, there should also be an Unfoldable class. This package provides one. Example unfolds are: * Random values * Enumeration of all values (depth-first or breadth-first) * Convert from a list Some examples can be found in the examples directory. Version 0.7.1