2 ms·
> one the two other important Haskell "design-patterns" (Functor - Applicative - Monad) These days you should probably add Foldable and Traversable to that lis
by nybble41 4y ago
> one the two other important Haskell "design-patterns" (Functor - Applicative - Monad)
These days you should probably add Foldable and Traversable to that list, as they are closely related and appear throughout the standard libraries and even in the Prelude.
Traversable is a generalization of Functor to include Applicative effects. It reduces to Functor if the Applicative happens to be the Identity type.
Where Functor and Traversable replace values one-to-one while preserving structure, Foldable represents reducing operations (folds) which consume the values from a structure in some defined order to build up a result. This includes basic functions like sums and products, as well as more complex operations like `sequence`.