Haskell Foldable Wast

John Wiegley johnw at newartisans.com
Wed Feb 17 23:03:53 UTC 2016


>>>>> amindfv  <amindfv at gmail.com> writes:

> I wouldn't expect a 2-tuple to be Foldable, particularly if 

> length (1, 2) = 1
> fold ("foo", "bar") = "bar"
> toList (3,4) = [4]
> elem 1 (1,2) = False
> etc, etc

I think the fact that toList (3,4) has a meaning that is not obvious to the
layman is a teaching matter. I read (x,4), in a Foldable context, as an
"annotated 4", and not as some kind of shorthand for a two-element collection.
My gut feeling is that the similarity to lists here is a specious argument;
and that of all the things that confuse newcomers, restricting our standard
library to avoid this scenario is energy spent in the wrong place.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2


More information about the Libraries mailing list