The dreaded M-R

Benjamin Franksen benjamin.franksen at
Mon Jan 30 20:10:36 EST 2006

On Tuesday 31 January 2006 01:37, Andrew Pimlott wrote:
> On Tue, Jan 31, 2006 at 12:57:18AM +0100, lennart at 
> > Quoting Andrew Pimlott <andrew at>:
> > >On Mon, Jan 30, 2006 at 11:06:29PM +0100, lennart at 
> > >>So I envisage that you'd turn off the warning in the same way as
> > >>you turn off the M-R today: by a type signature.
> > >
> > >But if people were happy adding type signatures for every
> > > polymorphic variable definition, they wouldn't be moving to
> > > eliminate the M-R, would they?  Or do I misunderstand?
> >
> > Well, my feeling is that the M-R is an ugly wart, and I want it
> > gone. But I'm still happy to put a type signature when I want
> > something to be polymorphic.
> Ok, I understand your position now.  But even given this view, I
> think the warning will be problematic.  First, when will the warning
> be emitted?  For all variable assignments without signatures, or only
> for those that the implementation fails to monomorphize (as an
> optimization)?  The first is heavy-handed; 


> the second, obviously 
> implementation-dependent (someone using another implementation, or
> another optimization level, will get the warning and will lose
> sharing). 

And what, if I may ask, is the problem with that? I mean, I am used to 
different implementations having, sometimes drastic, differences in 
speed or memory use. Getting a warning about possible loss of 
efficiency due to loss of sharing might be /very/ helpful; and it can 
safely be ignored by a beginner, as long as it is unmistakenly flagged 
as such (i.e. an efficiency warning, nothing /wrong/ with the code). 
Furthermore, you would turn on such a warning only if you are expressly 
interested in your program's efficiency. And in this case I would be 
thankful to get as many (substantial) warnings as possible.

> Second, a warning about "loss of sharing" may befuddle 
> beginners (who are usually not taught to write type signatures at the
> start).
> Well, maybe when someone implements this warning, we will find out
> I'm wrong and it doesn't cause trouble.   And I agree with removing
> the M-R, with or without the warning.

I would make it a strong recommendation for implementations to provide a 
warning about loss of sharing due to 'accidental' (=inferred) 
polymorphism/overloading, whenever it /actually happens/. But I would 
demand that it is not turned on by default, so as not to unsettle the 
unsuspecting beginner.


More information about the Haskell-prime mailing list