The monomorphism restriction and monomorphic pattern bindings
Iavor Diatchki
iavor.diatchki at gmail.com
Wed Apr 23 16:15:19 EDT 2008
Hello,
Removing the MR seems reasonable. I am a little less certain about
the MPB rule though. I suspect that, as the wiki page points out,
many uses of pattern bindings are monomorphic but still, there seem to
be a number of examples on the wiki where people have run into this
problem. So I am not sure that the conclusion that nobody has noticed
the change is valid. I do believe that you can probably work around
the problem in many situations but the question in my mind is "why
should we have to work around stuff when we have a system that already
works?" In other words, what problem do MBPs solve?
I should also point out that if we were to adopt the MBP rule, we
would have to adjust the definition of what pattern bindings mean.
For example, I think that this is how things are desugared at the
moment:
(x,y) = e
becomes
new_var = e
x = case new_var of (v,_) -> v
y = case new_var of (_,v) -> v
It seems that under MBP the second program is not equivalent to the
first because it is more polymorphic.
-Iavor
On Wed, Apr 23, 2008 at 10:32 AM, Simon Marlow <marlowsd at gmail.com> wrote:
> Folks,
>
> The current proposal on the table for what to do about the monomorphism
> restriction (henceforth MR) is
>
> * remove the MR entirely
> * adopt Monomorphic Pattern Bindings (MPB)
>
> Right now, the committee is almost uniformly in favour of dropping the MR,
> and most of us are coming round to the idea of MPB. Since this area has
> historically been difficult to achieve a concensus on, I'm excited that we
> appear to be close to making a decision, and a good one at that!
>
> The arguments for removing the MR are pretty well summarised on the wiki:
>
> http://hackage.haskell.org/trac/haskell-prime/wiki/MonomorphismRestriction
>
> You can read about MPB here:
>
>
> http://hackage.haskell.org/trac/haskell-prime/wiki/MonomorphicPatternBindings
>
> GHC has implemented MPB by default (i.e. we deviate slightly from Haskell
> 98) since 6.8.1.
>
> The nice thing about the combination of removing MR and adopting MPB is
> that we retain a way to explicitly declare monomorphic bindings. These are
> monomorphic bindings:
>
> ~x = e
> x at _ = e
>
> or if you don't mind a strict binding: !x = e. The wiki points out that
>
> (x) = e
>
> would also be monomorphic, but arguably this is in poor taste since we
> expect (x) to mean the same as x everywhere.
>
> Cheers,
> Simon
> _______________________________________________
> Haskell-prime mailing list
> Haskell-prime at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-prime
>
More information about the Haskell-prime
mailing list