[Haskell-cafe] Textbook example of instance Foldable ((,) a)

Manuel Schneckenreither manuel.schnecki at gmail.com
Tue Nov 24 09:55:21 UTC 2020


    >>>>> "TE" == Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk>
writes:

    TE> On Mon, Nov 23, 2020 at 09:54:26PM +0100, Francesco Ariis wrote:

    TE> Which of the following would they give up?

    TE> A. Foldable as superclass of Traversable

    TE> B. (a,) as Traversable

For me it is B. Even the Foldable hackage description states "Functors
representing data structures that can be traversed from left to right."
The tuple is however not traversed from left to right, but solely on the
right (as it's half filled).

For me it doesn't make sense to implement it, just because it's
implementable. I think the current implementation does not add more
value than it harms.


El lun., 23 nov. 2020 22:23, Tom Ellis <
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> escribió:

> On Mon, Nov 23, 2020 at 09:54:26PM +0100, Francesco Ariis wrote:
> > Il 23 novembre 2020 alle 14:40 Zemyla ha scritto:
> > > So what should maximum (2, "potato") be?
> >
> > For people who did not agree with `instance Foldable (,) a`, a
> > type error!
>
> Which of the following would they give up?
>
> A. Foldable as superclass of Traversable
>
> B. (a,) as Traversable
>
> Personally I think in retrospect I think I'd give up both and use
> explicit Traversals (i.e. optics instead).  That way one would have to
> write
>
>     allOf each (\ i -> contents p i == contents q i) ...
>
> By contrast
>
>     allOf _2 (\ i -> contents p i == contents q i) ...
>
> obviously looks wrong.
>
> Tom
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201124/f8bce972/attachment.html>


More information about the Haskell-Cafe mailing list