
On Fri, 2008-09-05 at 08:33 +0100, Ross Paterson wrote:
On Fri, Sep 05, 2008 at 07:06:54AM +0000, Bart Massey wrote:
I think it would be better to expand the definition of groupBy such that the equality test is applied only to adjacent elements (with the arguments in proper order).
I agree:
http://www.haskell.org/pipermail/haskell-cafe/2006-October/019148.html http://www.haskell.org/pipermail/libraries/2007-August/008031.html
We should do it this time. (Probably too late for 6.10, though.)
Yes, this behaviour surprised us when we were re-implementing the list library (as part of the stream fusion stuff). We assumed this was the behaviour and didn't catch it until we ran our quickcheck tests with randomly generated predicates. There's also a more efficient version that can be implemented if one is allowed to be slightly stricter and not return a group until the end of the group is encountered, but that's obviously not suitable for Data.List. (But it would be interesting if we could use RULES that could match on strictness properties.) Duncan