Implict parameters and monomorphism

John Hughes rjmh@cs.chalmers.se
Fri, 4 May 2001 09:27:51 +0200 (MET DST)


	> Except, of course, for top level bindings which is where the
	> monomorphism restriction is usually most noticable.

	Right, but an explicit monomorphic type signature would ensure that
	it's computed once. Type signatures on toplevel bindings are a good
	idea anyway, and there is no ambiguity for implicit parameters which
	must yield a function-like binding.

This is a matter of taste, and Haskell deliberately supports both a style with
and without type signatures on top-level bindings. I'd be sorry to see that
change. One good reason for NOT giving inferrable type signatures is that
including them makes programs less modifiable: a small local change, such as
adding a parameter to a type, may force a large number of consequential
changes to type signatures. I've seen cases where programmers refrained from a
significant improvement, because of the labour required to update type
signatures (which had been included, ironically, to disable the monomorphism
restriction!).

I'm not saying it's bad to give type signatures, just that there are arguments
for both styles, and the language ought not to make either one difficult to
use.

John