<div dir="ltr">As I recall, Richard Eisenberg has been pushing, off and on, for us to get a better vocabulary to specify "how" something is derived, via DeriveAnyClass, generalized newtype deriving, DeriveFoldable, etc.<div><br></div><div>In general I think the current behavior is the least surprising as it "walks all the a's it can" and is the only definition compatible with further extension with Traversable. Right now there are no instances provided by base that violate the "walk all the a's" intuition and there is a fair bit of user code for things like vector types that do things like</div><div><br></div><div>newtype V3 a = V3 (a,a,a,a)</div><div><br></div><div>replacing that with a data type isn't without cost because now converting back and forth between that and a tuple could no longer be done for zero cost with coercions. This style of code is more common among the ML-turned-haskeller crowd, whom -- in my experience -- tend to think of it as just giving the constructor paren around its arguments rather than as a tuple.</div><div><br></div><div>Destroying Foldable for that and making working code not work just for users to have to manually specify multiple tedious instances that should be easily derivable shouldn't be a thing we do lightly. DeriveFunctor doesn't consider that functors involved may be contravariant either. DeriveFoo generally does something that is a best effort.</div><div><br></div><div>I'm more inclined to leave it on the list of things that DeriveFoo does differently than GND, and as yet another argument pushing us to find a better vocabulary for talking about deriving.</div><div><br></div><div>-Edward</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 21, 2017 at 5:11 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The point is that there are two reasonable ways to do it, and the<br>
deriving mechanism, as a rule, does not make choices between<br>
reasonable alternatives.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Mar 21, 2017 at 5:05 PM, Jake McArthur <<a href="mailto:jake.mcarthur@gmail.com">jake.mcarthur@gmail.com</a>> wrote:<br>
> I think it's a question of what one considers consistent. Is it more<br>
> consistent to treat tuples as transparent and consider every component with<br>
> type `a`, or is it more consistent to treat tuples as opaque and reuse the<br>
> existing Foldable instance for tuples even if it might cause a compile time<br>
> error?<br>
><br>
><br>
> On Tue, Mar 21, 2017, 4:34 PM David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br>
>><br>
>> This seems much too weird:<br>
>><br>
>> *> :set -XDeriveFoldable<br>
>> *> data Foo a = Foo ((a,a),a) deriving Foldable<br>
>> *> length ((1,1),1)<br>
>> 1<br>
>> *> length $ Foo ((1,1),1)<br>
>> 3<br>
>><br>
>> I've opened Trac #13465 [*] for this. As I write there, I think the<br>
>> right thing is to refuse to derive Foldable for a type whose Foldable<br>
>> instance would currently fold over components of a tuple other than<br>
>> the last one.<br>
>><br>
>> I could go either way on Traversable instances. One could argue that<br>
>> since all relevant components *must* be traversed, we should just go<br>
>> ahead and do that. Or one could argue that we should be consistent<br>
>> with Foldable and refuse to derive it.<br>
>><br>
>> What do you all think?<br>
>><br>
>> [*] <a href="https://ghc.haskell.org/trac/ghc/ticket/13465" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/ticket/13465</a><br>
>> ______________________________<wbr>_________________<br>
>> Glasgow-haskell-users mailing list<br>
>> <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.<wbr>org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/glasgow-<wbr>haskell-users</a><br>
______________________________<wbr>_________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.<wbr>org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/glasgow-<wbr>haskell-users</a><br>
</div></div></blockquote></div><br></div>