Foldable doesn’t have to be a superclass of Traversable.
Removing it only requires a few minor changes to existing code.
From: Libraries [mailto:libraries-bounces@haskell.org]
On Behalf Of Marcin Mrotek
Sent: 21 February 2016 09:05
To: Jeremy
Cc: Haskell Libraries
Subject: Re: Haskell Foldable Wast
It may be that some of the Foldable methods for tuples happen to be useful,
but this does not mean that tuples are foldable.
I think that, as far as Foldable is concerned, a tuple is equivalent to Identity, so this instance is indeed useless. However, Foldable is a superclass of Traversable (and it wouldn't make much sense to make these classes unrelated, as
one can always define folds with `traverse`), so I've always found it a necessary evil. Either's instance for Foldable is a little more useful, but equivalent to Maybe's, I think?
But there are, in general, at least two separate use cases for these instances:
a) Using Foldable methods directly on tuples or Eithers - I think it's usually pointless, as I wrote above.
b) Passing a tuple/Either/Maybe/whatever to a more complicated function that requires a Foldable constraint. This is potentially much more useful, and at least saves some wrapping/unwrapping.
Best regards,
Marcin Mrotek