DeriveFoldable treatment of tuples is surprising

Ryan Scott ryan.gl.scott at gmail.com
Wed Mar 22 13:47:32 UTC 2017


I believe what Sven was saying is not that the Foldable instance for tuples
are given "special treatment" (which is arguably an orthogonal discussion),
but rather that -XDeriveFoldable special-cases tuples, which is certainly
true.

As Edward noted, there is one possible justification for this behavior
w.r.t. things like newtype V3 a = V3 (a, a, a) deriving Foldable. But to be
honest, I find this justification tenuous at best, given the confusion it
causes when explaining how DeriveFunctor/DeriveFoldable/DeriveTraversable
work to newcomers. Removing this special case would not only be simple, but
it would also lead to a more consistent story overall.

I would be curious to know how much code in the wild is actually taking
advantage of a trick like newtype V3 a = V3 (a, a, a) deriving Foldable. If
the breakage isn't terrible, then I propose we just rip off this wart.

(This is basically a rehash of the thoughts I left at
https://ghc.haskell.org/trac/ghc/ticket/13465#comment:3)

Ryan S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20170322/8c0c4146/attachment.html>


More information about the ghc-devs mailing list