
[Errk, somehow posted this with no Subject. Trying again.]
On Sun Apr 9 19:24:12 UTC 2017, Sven Panne wrote:
2017-04-09 2:01 GMT+02:00 Ben Franksen :
Am 08.04.2017 um 04:03 schrieb Anthony Clayden: [...] So to take your examples from an earlier thread, what do you expect Haskell to do here?:
maximum (True,2) => ? minimum ((3, 4),5) => ? -- i.e. :: ((Int, Int), Int) sum (7,3.14) => ? -- i.e. :: (Int, Double) product (Left $ error "Errk") => ? -- i.e. :: Either e Int
I (and others) think these should be type errors.
Exactly.
OK. Do y'all think there should be a `toList` method for them? Indeed, should there be a `toList` method available for any data type that doesn't implement `fromList`? Perhaps `toList` should not be a method of Foldable?
Do you expect Foldable (a, a) to behave differently vs Foldable (b, a) vs Foldable ((a, a), a) vs ...?
It would be nice if we could all agree on removing these instances.
Yep. :-)
BTW, I find it remarkable that of those who defend these instances, few seem to be especially interested in clarifying the OP's question: what laws exactly do we expect for Foldable? [...]
One of the Laws appears to be that `length` etc behave as `length . toList`. AntC
participants (1)
-
Anthony Clayden