Haskell Foldable Wast

Marcin Mrotek marcin.jan.mrotek at gmail.com
Sun Feb 21 09:04:48 UTC 2016


>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160221/5093739f/attachment.html>


More information about the Libraries mailing list