Haskell 98 Report

Fergus Henderson fjh@cs.mu.oz.au
Fri, 1 Jun 2001 04:19:23 +1000


On 31-May-2001, Simon Peyton-Jones <simonpj@microsoft.com> wrote:
> We should either generalise all three
> 	deleteBy
> 	deleteFirstsBy
> 	intersectBy
> or none.
> 
> In favour:
> 	the more general types are occasionally useful
> 	no programs stop working

Actually some programs will stop working, because the types will be
underconstrained, so the compiler won't know how to satisfy some type class
constraint.

For example:

	import List
	main = print (deleteBy (\x _y -> x > 0) 1 [])

With the generalized type, you'd get an unresolved `Show' constraint.

The number of real programs for which this is a problem is most likely very
small, and the work-around (typically just adding an explicit type
qualification) is not hard once you understand what the problem is, but
figuring out what the problem is could take some time.

Since it does break some obscure programs, and since it's easy enough
for programmers who want a generalized version to just cut and paste
the code from the Haskell report and give it a more general type signature,
my preference would be to leave this out of Haskell 98, but include it
in the next version of Haskell. 

(It would be good for someone, perhaps Simon P-J., to keep a list of
issues like this which have been left out of Haskell 98 due to backwards
compatibility concerns, so that they don't get forgotten about when it
comes to time for the next version.)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.