The dreaded M-R
simonmar at microsoft.com
Thu Jan 26 09:28:29 EST 2006
On 26 January 2006 09:59, John Hughes wrote:
> The solution I favour is simply to use *different syntax* for the two
> forms of binding, so that a definition is monomorphic, and computed
> at most once, if it uses the monomorphic binding operator, and
> polymorphic/overloaded, computed at each use, if it uses the other.
> Whether it's a function definition or not is irrelevant, as is whether
> or not it carries a type signature.
> The trick is finding good syntax. I suggest = for bind-by-name, and
> := for bind-by-need.
The reasoning for the proposal makes complete sense to me, but I don't
feel the proposed solution strikes the right balance. The MR is a
subtle point that we don't want to have to burden newcomers to the
language with, but having two forms of binding is a fundamental part of
the language design that would surely crop up early on the Haskell
learning curve. John - how do you envisage teaching this?
I wonder if there's an alternative solution along these lines:
- We use ParialTypeSignatures to make bindings monomorphic:
x :: _
x = (+1)
(incedentally until recently it was possible to do this
in GHC using scoped type variables, but the change in the semantics
of scoped type variables has removed that possibility).
- we make it a static error for a variable bound by a simple pattern
binding ("x = e") to be overloaded, unless a type signature is
The error message would explain the problem, and how to fix it.
Alternatively, we make it a strong warning.
It seems to me that the partial type signatures extension provides a lot
of bang for the buck - it gives us a way out of the MR in addition to
partial type signatures.
I'm not sure what to do about non-simple pattern bindings, though.
More information about the Haskell-prime