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

Zemyla zemyla at gmail.com
Mon Nov 23 20:40:55 UTC 2020


So what should maximum (2, "potato") be?

On Mon, Nov 23, 2020, 14:19 Sven Panne <svenpanne at gmail.com> wrote:

> Am Mo., 23. Nov. 2020 um 16:32 Uhr schrieb Sebastiaan Joosten <
> sjcjoosten+haskell at gmail.com>:
>
>> [...] We obtain: length (a,b) = length [b] = 1
>>
>
> Quoting my former self (
> https://mail.haskell.org/pipermail/libraries/2017-April/027905.html), you
> get even more "fun" stuff with lots of potential for late-night debugging
> hours:
>
>    maximum (3,2)   =>   2
>    minimum (4,5)   => 5
>    sum (6,7)   =>   7
>    product (8,9)   =>   9
>
> Yes, you can think of (X, Y) as "Y with context X" or "a one-element container with Y in it", but is this really what comes to your mind first? I still highly doubt that. The Foldable-Traversable-in-Prelude change was largely a good thing, but very surprising (and not really needed) changes coming stealthily with it were only communicated when it was already too late... :-/
>
> _______________________________________________
> 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/20201123/e72e8b80/attachment.html>


More information about the Haskell-Cafe mailing list