DeriveFoldable treatment of tuples is surprising

Ryan Yates fryguybob at gmail.com
Wed Mar 22 13:54:03 UTC 2017


Thanks for the clarification!

Ryan

On Wed, Mar 22, 2017 at 9:47 AM, Ryan Scott <ryan.gl.scott at gmail.com> wrote:

> 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.
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20170322/0580d8ed/attachment.html>


More information about the ghc-devs mailing list