... | ... | @@ -18,8 +18,6 @@ It has recently been highlighted that as these changes affect the `Prelude`, and |
|
|
|
|
|
However, there are many good reasons to do both the AMP and FTP generalizations at this time.
|
|
|
|
|
|
- **By generalizing the `Prelude`, the `Prelude` will no longer cause name collisions anywhere within `base`**. This is a very simple rule to state; it is a very simple rule to understand. This is no panacea, other packages can and do still export combinators that collide with `Prelude`, but it means that simple things like explaining how `traverse` relates to `mapM` in `ghci` will no longer invite a comedy of errors and name conflicts.
|
|
|
|
|
|
- **`Foldable` and `Traversable` 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](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. [ An Investigation of the Laws of Traversals](http://arxiv.org/pdf/1202.2919v1.pdf) is one such paper, providing the common sense reading of the `Traversable` laws.
|
... | ... | @@ -28,6 +26,8 @@ However, there are many good reasons to do both the AMP and FTP generalizations |
|
|
|
|
|
- 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 and are **harder to use for the simple reason that using them requires qualified imports or massive amounts of manual hiding**.
|
|
|
|
|
|
- **By generalizing the `Prelude`, the `Prelude` will no longer cause name collisions anywhere within `base`**. This is a very simple rule to state; it is a very simple rule to understand. This is no panacea, other packages can and do still export combinators that collide with `Prelude`, but it means that simple things like explaining how `traverse` relates to `mapM` in `ghci` will no longer invite a comedy of errors and name conflicts.
|
|
|
|
|
|
- Nothing in `Foldable` or `Traversable` ever changes the "shape" of the container it is given. This is actually more information for the user than seeing a combinator accepts any list and returns any list. While we give up the knowledge that the thing we're walking over is a list, we gain information as well. **The more general signatures can often tell the user more** about what a combinator can do behind the scenes. e.g. we can know that `forM` will not change the number of elements in the container by leaning on the `Traversable` laws alone and the lack of any other way to construct the result value. We're not just able to rely the fact that it gives back a list, but we can rely on the specific shape of the structure we get back.
|
|
|
|
|
|
- At the time of the "Burning Bridges Proposal" thread on the libraries mailing list back in 2013, this question was widely polled, and there was an **overwhelmingly strong call from the community for generalization**. Admittedly, this was from the self-selecting subset of the community that is active on the [ libraries@ mailing list](https://www.haskell.org/mailman/listinfo/libraries).
|
... | ... | |