Portability | portable |
---|---|
Stability | provisional |
Maintainer | John Goerzen <jgoerzen@complete.org> |
Generic tools for data structures that can be folded.
Written by John Goerzen, jgoerzen@complete.org
- class FoldableLL full item | full -> item where
- fold :: (FoldableLL full item, Monoid item) => full -> item
- foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m
FoldableLL Class
class FoldableLL full item | full -> item whereSource
This is the primary class for structures that are to be considered
foldable. A minimum complete definition provides foldl
and foldr
.
Instances of FoldableLL
can be folded, and can be many and varied.
These functions are used heavily in Data.ListLike.
foldl :: (a -> item -> a) -> a -> full -> aSource
Left-associative fold
foldl' :: (a -> item -> a) -> a -> full -> aSource
Strict version of foldl
.
foldl1 :: (item -> item -> item) -> full -> itemSource
A variant of foldl
with no base case. Requires at least 1
list element.
foldr :: (item -> b -> b) -> b -> full -> bSource
Right-associative fold
foldr' :: (item -> b -> b) -> b -> full -> bSource
Strict version of foldr
foldr1 :: (item -> item -> item) -> full -> itemSource
Like foldr
, but with no starting value
FoldableLL ByteString Word8 | |
FoldableLL ByteString Word8 | |
FoldableLL [a] a | |
Ix i => FoldableLL (Array i e) e | |
Ord key => FoldableLL (Map key val) (key, val) |
Utilities
fold :: (FoldableLL full item, Monoid item) => full -> itemSource
foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> mSource
Map each element to a monoid, then combine the results