The introduction of
Applicative
, along with Foldable
and Traversable
, have had a big impact on Haskell.
The Foldable
and Traversable
typeclasses lift the Prelude fold
and map
functions to a much higher level of abstraction. Moreover, Foldable
and Traversable
also bring a clean separation between processes that preserve or discard the shape of the structure being processed:
Traversable
describes a process that preserves the shape of the data structure being traversed overFoldable
discards (or transforms) the shape of the structure being folded over
Since Traversable
is a specialization of Foldable
, we can say that shape preservation is a special case of shape transformation. This line between shape preservation and transformation is clearly visible from the fact that functions that discard their result (for example, mapM_
, forM_
, sequence_
, and so on) are in Foldable
, while their shape-preserving counterparts are in Traversable
.
Due to the relatively late introduction...