[Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of
numeric constants)
Bernie Pope
bjpop at csse.unimelb.edu.au
Sat Sep 23 12:18:55 EDT 2006
On 24/09/2006, at 1:46 AM, Michael Shulman wrote:
> On 9/23/06, Bernie Pope <bjpop at csse.unimelb.edu.au> wrote:
>> If a pattern binding is not simple, it must have a data constructor
>> on the lhs, therefore it cannot be overloaded. So the (dreaded) MR
>> only
>> applies to simple pattern bindings.
>
> I thought it was simple pattern bindings that could be *exempted* from
> the MR by supplying an explicit type signature, while non-simple
> pattern bindings are always subject to it.
>
Actually, I realised after I posted my message that what I wrote was
dubious. I'm sorry about that, please ignore it.
This section from the Report seems to clear things up:
In "Motivation", section 4.5.5:
"Rule 1 prevents ambiguity. For example, consider the declaration group
[(n,s)] = reads t
Recall that reads is a standard function whose type is given by the
signature
reads :: (Read a) => String -> [(a,String)]
Without Rule 1, n would be assigned the type forall a. Read a =>a and
s the type forall a. Read a =>String. The latter is an invalid type,
because it is inherently ambiguous. It is not possible to determine
at what overloading to use s, nor can this be solved by adding a type
signature for s. Hence, when non-simple pattern bindings are used
(Section 4.4.3.2), the types inferred are always monomorphic in their
constrained type variables, irrespective of whether a type signature
is provided. In this case, both n and s are monomorphic in a."
Sorry for the confusion,
Bernie.
More information about the Haskell-Cafe
mailing list