
On 2008-08-26, Jim Apple
Why isn't the type of group
Eq a => [a] -> [(a,[a])]
That matches more exactly what group does, and it's easy to see that functions like
nubOrd = map fst . group . sort
are clearly safe, whereas
map head . group . sort
is not.
I think the big thing is that while this is safer type, it's also much harder to use. Knowing I have a non-empty list is certainly useful information that can be reasoned about at the type level, but if I can't pass them easily to normal list functions, it's much less useful. Perhaps judicious use of typeclasses would make this easier, but I don't think those were in the original either. In any case the design space for a standard prelude that had the normal list type and a non-empty list type united in a sequence class is rather large, particularly if it's an open class that new sequence-like data types are expected to be an instance of. -- Aaron Denney -><-