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

Henning Thielemann lemming at henning-thielemann.de
Mon Nov 23 15:09:40 UTC 2020


On Mon, 23 Nov 2020, Manuel Schneckenreither wrote:

>    >>>>> "SP" == Sven Panne <svenpanne at gmail.com> writes:
>
>    SP> Am Mo., 23. Nov. 2020 um 14:54 Uhr schrieb Johannes Waldmann
>    SP> <johannes.waldmann at htwk-leipzig.de>: [...] Henning already
>    SP> called this "Matlab league" behaviour,
>    SP> https://mail.haskell.org/pipermail/libraries/2016-February/026678.html
>
> What is the intiutive way of implementing the tuple instance like this [1]
>
>    instance Foldable ((,) a) where
>      ..
>      length _ = 1
>      ..
>
> I cannot come up with a real argument, except to say there is something.

"length (a,b) == 1" is only a consequence of defining instance Foldable 
for pairs. It was not the argument to implement that instance, at all.


More information about the Haskell-Cafe mailing list