Incoherence
John Hughes
rjmh@cs.chalmers.se
Thu, 25 Oct 2001 09:21:41 +0200 (MET DST)
John Hughes wrote:
> What we need is different binding syntax for monomorphic and polymorphic
> bindings. Roll on := and = ...
I agree absolutely that we need such a distinction. Although it's
worth clarifying a point. The monomorphism restriction doesn't
exclude polymorphism, just overloading, e.g. I can bind `x = []' with
no problem. So is your proposal to have := bind non-overloaded (and
non-implicitly parameterized terms), or do you really mean that it
will only bind monomorphic terms? (thus `x := []' would be
problematic, unless there's a type sig).
--Jeff
My proposal is that := should bind *monomorphically* -- just like lambda
binding. The motivation for that is that a polymorphic function can easily
become overloaded after a small change to the program, such as adding removal
of duplicate elements from a list. Such changes shouldn't cause wholesale
differences in typing -- which the MR currently can. Another way to look at it
is that = should imply type generalisation (including qualification), and
:= should mean no generalisation. It's a little odd to support *two kinds*
of generalisation (with and without qualification).
`x := []' wouldn't be problematic, just monomorphic. That is, x must be used
consistently as a list of a particular type. But that need not prevent the
type that x has from being inferred from its uses.
John