Re: DeriveFoldable treatment of tuples is surprising

2017-03-22 Thread Ryan Yates
Thanks for the clarification! Ryan On Wed, Mar 22, 2017 at 9:47 AM, Ryan Scott 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 tupl

Re: DeriveFoldable treatment of tuples is surprising

2017-03-22 Thread Ryan Scott
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 beha

Re: DeriveFoldable treatment of tuples is surprising

2017-03-22 Thread Ryan Yates
On Wed, Mar 22, 2017 at 4:12 AM, Sven Panne wrote: > 2017-03-21 22:29 GMT+01:00 Edward Kmett : > >> [... 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. [...] >> >

Re: DeriveFoldable treatment of tuples is surprising

2017-03-22 Thread Sven Panne
2017-03-21 22:29 GMT+01:00 Edward Kmett : > [... 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. [...] > OTOH, the current behavior contradicts my intuition that wra

Re: DeriveFoldable treatment of tuples is surprising

2017-03-21 Thread Edward Kmett
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. In general I think the current behavior is the least surprising as it "walks all the a's it c

Re: DeriveFoldable treatment of tuples is surprising

2017-03-21 Thread Oleg Grenrus
For `Traversable` one have to `traverse` over everything: traverse @Foo = forall f. Applicative f => (a -> f b) -> Foo a -> f (Foo b) ~= -> ((a,a), a) -> f ((b,b), b) And thus the same behavior for `Foldable`. You should define: data Foo b a = Foo ((b,b), a) deriving Foldable

Re: DeriveFoldable treatment of tuples is surprising

2017-03-21 Thread David Feuer
The point is that there are two reasonable ways to do it, and the deriving mechanism, as a rule, does not make choices between reasonable alternatives. On Tue, Mar 21, 2017 at 5:05 PM, Jake McArthur wrote: > I think it's a question of what one considers consistent. Is it more > consistent to trea

DeriveFoldable treatment of tuples is surprising

2017-03-21 Thread David Feuer
This seems much too weird: *> :set -XDeriveFoldable *> data Foo a = Foo ((a,a),a) deriving Foldable *> length ((1,1),1) 1 *> length $ Foo ((1,1),1) 3 I've opened Trac #13465 [*] for this. As I write there, I think the right thing is to refuse to derive Foldable for a type whose Foldable instance