New classes for traversals
The following modules may be used for general traversals over containers.
They are included in the base package
(because instances need access to internal representations)
and will appear in future releases of Haskell implementations.
- Control.Applicative
(source)
- defines a class
Applicative
(formerly known as Idiom) that generalizes (but does not replace) both
Monad
and
Monoid.
- Data.Traversable
(source)
- defines a class
Traversable
of containers that can be traversed, executing actions and re-assembling
the results.
This class generalizes and replaces
FunctorM,
because it requires
Applicative
instead of
Monad.
- Data.Foldable
(source)
- defines a class
Foldable
of containers that can be folded over a
Monoid,
and lots of derived folds.
Data.Traversable
supplies a default definition, but some structures, e.g.
Set,
are
Foldable
but not
Traversable.
There is also a
draft paper
about applicative and traversable functors.
Please email comments to
libraries@haskell.org.
Conor McBride
and
Ross Paterson.