class Foldable f where
Foldable represents data structures which can be folded.
foldrfolds a structure from the right
foldlfolds a structure from the left
foldMapfolds a structure by accumulating values in a
Default implementations are provided by the following functions:
Note: some combinations of the default implementations are unsafe to use together - causing a non-terminating mutually recursive cycle. These combinations are documented per function.
foldr :: forall a b. (a -> b -> b) -> b -> f a -> b
foldl :: forall a b. (b -> a -> b) -> b -> f a -> b
foldMap :: forall a m. Monoid m => (a -> m) -> f a -> m
for_ :: forall a b f m. Applicative m => Foldable f => f a -> (a -> m b) -> m Unit
A version of
traverse_ with its arguments flipped.
This can be useful when running an action written using do notation for every element in a data structure:
for_ [1, 2, 3] \n -> do print n trace "squared is" print (n * n)