<p dir="ltr">I think it's a question of what one considers consistent. Is it more consistent to treat tuples as transparent and consider every component with type `a`, or is it more consistent to treat tuples as opaque and reuse the existing Foldable instance for tuples even if it might cause a compile time error?</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Mar 21, 2017, 4:34 PM David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This seems much too weird:<br class="gmail_msg">
<br class="gmail_msg">
*> :set -XDeriveFoldable<br class="gmail_msg">
*> data Foo a = Foo ((a,a),a) deriving Foldable<br class="gmail_msg">
*> length ((1,1),1)<br class="gmail_msg">
1<br class="gmail_msg">
*> length $ Foo ((1,1),1)<br class="gmail_msg">
3<br class="gmail_msg">
<br class="gmail_msg">
I've opened Trac #13465 [*] for this. As I write there, I think the<br class="gmail_msg">
right thing is to refuse to derive Foldable for a type whose Foldable<br class="gmail_msg">
instance would currently fold over components of a tuple other than<br class="gmail_msg">
the last one.<br class="gmail_msg">
<br class="gmail_msg">
I could go either way on Traversable instances. One could argue that<br class="gmail_msg">
since all relevant components *must* be traversed, we should just go<br class="gmail_msg">
ahead and do that. Or one could argue that we should be consistent<br class="gmail_msg">
with Foldable and refuse to derive it.<br class="gmail_msg">
<br class="gmail_msg">
What do you all think?<br class="gmail_msg">
<br class="gmail_msg">
[*] <a href="https://ghc.haskell.org/trac/ghc/ticket/13465" rel="noreferrer" class="gmail_msg" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/13465</a><br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Glasgow-haskell-users mailing list<br class="gmail_msg">
<a href="mailto:Glasgow-haskell-users@haskell.org" class="gmail_msg" target="_blank">Glasgow-haskell-users@haskell.org</a><br class="gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users</a><br class="gmail_msg">
</blockquote></div>