Implict parameters and monomorphism

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
3 May 2001 22:23:19 GMT


Thu, 3 May 2001 15:26:38 -0600, Alastair Reid <reid@cs.utah.edu> pisze:

>> You can always use 'case' instead of 'let' for variable bindings.
> 
> 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.

> Unless I missed something, reason (2) prevents us from completely
> getting rid of the restriction even if we are willing to ignore (1).

Ok. Let's keep (2) and remove (1).

ghc -fno-monomorphism-restriction allows polymorphis cases like (2)
and they do create ambiguous types like Read a => String. I would treat
it as a bug: removing monomorphism restriction should not go that far.
Haskell 98 doesn't allow removing it for pattern bindings by supplying
a type signature.

Here is a crazy idea: either of these
    ~x  = ...
    x@_ = ...
creates a pattern binding, so it's a way of writing it without a type
signature if there was no monomorphic restriction :-)

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK