... | ... | @@ -13,11 +13,11 @@ However, there are many good reasons to do both the AMP and FTP generalizations |
|
|
|
|
|
- `Foldable` and `Traversable` are abstractions that have seen long use in the Haskell community, predating even the existence of `Applicative`, dating back into the early 2000s. We know and have tested these abstractions, and they have deep explanatory power.
|
|
|
|
|
|
- `Traversable` in particular has given us insight into the nature of finitary traversals and have been the subject of many papers since Jeremy Gibbons wrote "The Essence of the Iterator Pattern" each of which has managed to narrow the set of laws until we're left with only the obvious generalization of the `Functor` laws that allows for `Applicative` effects.
|
|
|
- `Traversable` in particular has given us insight into the nature of finitary traversals and have been the subject of many papers since Jeremy Gibbons wrote [ The Essence of the Iterator Pattern](http://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf) each of which has managed to narrow the set of laws until we're left with only the obvious generalization of the `Functor` laws that allows for `Applicative` effects. \[[ Investigation of the Laws of Traversals"](http://arxiv.org/pdf/1202.2919v1.pdf|"An) is one such paper, providing the common sense reading of the `Traversable` laws.
|
|
|
|
|
|
- Despite broad explanatory power and the ability to derive connections between a large chunk of the combinators that came before these abstractions were even named, they remain relegated to modules off to the side that contain combinators that are harder to use for the simple reason that using them requires qualified imports or massive amounts of manual hiding.
|
|
|
- However, `Traversable` is too strong a requirement for many of the operations it enables. `foldMap` is what you get when you limit the power of `traverse` to just consumption, so `Foldable` has a role in this hierarchy. It is particularly telling that almost all the interesting combinators enabled by `Traversable` are actually enabled by merely `Foldable` constraints, including some at-first-surprising results such as `traverse_`. `Foldable` shows us a fairly deep connection between 33+ seemingly unrelated operations from the `Prelude`. `Traversable` adds connections between several more to that mix.
|
|
|
|
|
|
- `Foldable` shows us a fairly deep connection between 33+ seemingly unrelated operations from the `Prelude`. `Traversable` adds connections between several more to that mix.
|
|
|
- Despite this broad explanatory power and the ability to derive connections between a large chunk of the combinators that came before these abstractions were even named, they remain relegated to modules off to the side that contain combinators that are harder to use for the simple reason that using them requires qualified imports or massive amounts of manual hiding.
|
|
|
|
|
|
- Once we make `Applicative` a superclass of `Monad`, `mapM` is basically \*never\* the right combinator for, well, anything. It requires too tight a constraint (`Monad` rather than `Applicative`) on one hand. Going the 'wrong' direction and adding a monomorphized `traverse` breaks far more code, and makes the scoping problems even worse.
|
|
|
|
... | ... | |