Deprecate Foldable for Either
Francesco Ariis
fa-ml at ariis.it
Thu Mar 2 16:58:53 UTC 2017
On Thu, Mar 02, 2017 at 05:22:48PM +0100, Andreas Abel wrote:
> Today a student came to me wondering why a certain function produced a
> regular result, where he had expected an error. Turned out he had used
> `concat`, but not on a lists of lists as he had thought, but on a lists of
> `Either a [b]`.
I keep making the same mistake when using Parsec to process a file;
calling `length` on the result (to check how many thingies I have
parsed) returns 1, 1 and again 1, no matter how many times I tinker
with the code.
I feel such a fool after recognising my misstep, every time.
> With the Foldable instance for Either, which considers Either a b to be a
> container of 0-1 elements of b, errors are happily swallowed.
>
> I think this instance is harmful and should be deprecated (and later
> removed) from base.
>
> There are similarly pointless Foldable instances as well.
>
> See a discussion one year ago, which was heated, but had no consequences.
I suspect it had no consequences because the mother of all battles was
"Foldable and Traversable to become importable unqualified"; and once
you set the goal (and reap the benefits: Traversable), you have to live
with some of the annoying consequences.
More information about the Libraries
mailing list