Haskell Foldable Wast

amindfv at gmail.com amindfv at gmail.com
Wed Feb 17 19:58:55 UTC 2016

El 17 feb 2016, a las 14:03, John Wiegley <johnw at newartisans.com> escribió:

>>>>>> amindfv  <amindfv at gmail.com> writes:
>> maximum(99, 0) = 0
> I don't quite understand; are you saying you expect Foldable to treat a tuple
> as a 2-element list?  If it did, would that better or worse?
> And if it should, then what would you expect this to mean:
>    maximum("Hello", 0)
> Or do you want both to be errors?

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

If I have a tuple foo and a list foo', I'd hope for an error if I write the wrong name, not silently acting wonky. This will cause real bugs.

(Also I've seen newcomers accidentally "parenthesize" with functions, so writing "maximum(99,0)" could be an attempt to write "max 99 0")

Part of the power of a type system is which program it rejects, and I'm arguing we're cluttering the space of valid programs.

This isn't a criticism of the FTP in general (which I largely supported, and whose ship has sailed). It's about a few "wtf" instances which cause silent errors.


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

More information about the Libraries mailing list