Modernizing Haskell 98

The introduction of Applicative, along with Foldable and Traversable, have had a big impact on Haskell.

The Foldable and Traversable type­classes 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 over
  • Foldable 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 of Applicative, the benefits of Foldable and Traversable have only recently found their way into the core of the language.

This change was managed under the "Foldable Traversable in Prelude" proposal (planned for inclusion in the core libraries from GHC 7.10), which can be found at https://wiki.haskell.org/Foldable_Traversable_In_Prelude.

The proposal involves replacing less generic functions in Prelude, Control.Monad, and Data.List with their more polymorphic counterparts in Foldable and Traversable.

There have been objections to this modernization, the main concern being that more generic types are harder to understand and that this may compromise Haskell as a learning language. While these valid concerns will indeed have to be addressed, it has not prevented the Haskell community from climbing to new abstract heights.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset