
Hi all, I've made a ticket and proposal page for removing the monomorphism restriction: http://hackage.haskell.org/trac/haskell-prime/ticket/131 http://hackage.haskell.org/trac/haskell-prime/wiki/NoMonomorphismRestriction Thanks Ian

On 25/07/2009 16:28, Ian Lynagh wrote:
I've made a ticket and proposal page for removing the monomorphism restriction: http://hackage.haskell.org/trac/haskell-prime/ticket/131 http://hackage.haskell.org/trac/haskell-prime/wiki/NoMonomorphismRestriction
I think if we do this we really have to do http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSema... Which is not strictly speaking a change, but is a necessary clarification if the MR is removed. I believe the conclusion we came to in March/April 2008 was to do this. Cheers, Simon

| > I've made a ticket and proposal page for removing the monomorphism | > restriction: | > http://hackage.haskell.org/trac/haskell-prime/ticket/131 | > http://hackage.haskell.org/trac/haskell-prime/wiki/NoMonomorphismRestriction | | I think if we do this we really have to do | | http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSema... Apropos of the MR, I'd like to invite you to read Let should not be generalised Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers Submitted to POPL 2010 http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/ind... Abstract: From the dawn of time, all derivatives of the classic Hindley-Milner type system have supported implicit generalisation of local let-bindings. Yet, as we will show, for more sophisticated type systems implicit let-generalisation imposes a disproportionate complexity burden. Moreover, it turns out that the feature is very seldom used, so we propose to eliminate it. The payoff is a substantial simplification, both of the specification of the type system, and of its implementation. The paper makes the (somewhat radical) case for not generalising local bindings at all; which would at a stroke remove most of the issues of the MR. (We'd still need to think about the top level.) We'd love to know what any of you think of the idea. Simon | -----Original Message----- | From: haskell-prime-private-bounces@haskell.org [mailto:haskell-prime-private- | bounces@haskell.org] On Behalf Of Simon Marlow | Sent: 27 July 2009 11:13 | To: haskell-prime@haskell.org; haskell-prime-private@haskell.org | Subject: Re: [Haskell'-private] NoMonomorphismRestriction | | On 25/07/2009 16:28, Ian Lynagh wrote: | | > I've made a ticket and proposal page for removing the monomorphism | > restriction: | > http://hackage.haskell.org/trac/haskell-prime/ticket/131 | > http://hackage.haskell.org/trac/haskell-prime/wiki/NoMonomorphismRestriction | | I think if we do this we really have to do | | http://hackage.haskell.org/trac/haskell-prime/wiki/SpecifyPatternBindingSema... | | Which is not strictly speaking a change, but is a necessary | clarification if the MR is removed. I believe the conclusion we came to | in March/April 2008 was to do this. | | Cheers, | Simon | _______________________________________________ | Haskell-prime-private mailing list | Haskell-prime-private@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-prime-private

The paper makes the (somewhat radical) case for not generalising local bindings at all; which would at a stroke remove most of the issues of the MR. (We'd still need to think about the top level.)
We'd love to know what any of you think of the idea.
I read the paper (except section 5 which is very technical). I like that it makes (let x = ... in ...) behave the same as (\x -> ...) (...) . Understanding how to respond to type inference and error messages is hard enough without having additional differences in innocent-looking code. Do you think my hope is reasonable that not-generalizing could lead to better error messages? I don't quite understand the issues[*], but I suspect that not-generalizing would at least make *me* less confused when fixing error messages because there are fewer different typechecker behaviors to think about. I guess it's still possible to use explicit type-signatures to make let-bindings polymorphic, in a way that is difficult or impossible for lambda or case? (I guess for lambda, it would require making the lambda into a rank-2 function, though I'm not sure how to do that syntactically.) [*] e.g., the gmapT / rank-2 example confuses me; would it work if (...blah...) were passed directly to gmapT without the let? Also, does it happen to solve the 2^n worst-case typechecking? -Isaac

| . Understanding how to respond to type inference and error messages is | hard enough without having additional differences in innocent-looking | code. Do you think my hope is reasonable that not-generalizing could | lead to better error messages? I don't think it's obvious one way or the other. We'll have to see. | typechecker behaviors to think about. I guess it's still possible to | use explicit type-signatures to make let-bindings polymorphic, Yes, just so | in a way | that is difficult or impossible for lambda or case? (I guess for lambda, | it would require making the lambda into a rank-2 function, though I'm | not sure how to do that syntactically.) Easy: \(x :: forall a. a->a) -> blah Simon

On Fri, Aug 7, 2009 at 1:04 PM, Simon Peyton-Jones
| . Understanding how to respond to type inference and error messages is | hard enough without having additional differences in innocent-looking | code. Do you think my hope is reasonable that not-generalizing could | lead to better error messages?
I don't think it's obvious one way or the other. We'll have to see.
The Bluespec experience with local bindings (complicated by our "imperative desugaring", but my opinion is that's mostly an irrelevant complication) is that automatically generalized local bindings create all sorts of user-level havoc: poor error messages for one, programs that surprisingly typecheck or have other surprising behaviors and so on. And I wouldn't blame these issues on Bluespec's desire to hide the type system details from our users - when some sort of polymorphism-related problem is discovered it is common for people at Bluespec itself to be confused and have trouble isolating the underlying issue. Based on that experience, I'd expect that removing the automatic generalization of local bindings would lead to many positive user-level side-effects that are independent of any implementation simplifications that result. In fact, when I first heard the suggestion (via Joe Stoy) I started looking for an excuse to end (or at least limit) Bluespec's generalization of local bindings, since I think the backwards compatibility issues that result will be more than worth it in the long run. - Ravi

On 6 Aug 2009, at 12:18, Simon Peyton-Jones wrote:
The paper makes the (somewhat radical) case for not generalising local bindings at all; which would at a stroke remove most of the issues of the MR. (We'd still need to think about the top level.)
Only the other day I was writing some code that used a case analysis to build a value I hoped would be polymorphic, and it kept refusing to type-check. Doing the case analysis on a different part of the value, then cutting and pasting the branch code multiple times did however seem to work. Suddenly I remembered about the difference in generalisation between let- and lambda- bindings, and could solve the problem by changing the case to a let! Instantly I could delete the error-prone cut-n-paste copies, and be more assured of the consistency of my code. Regards, Malcolm
participants (6)
-
Ian Lynagh
-
Isaac Dupree
-
Malcolm Wallace
-
Ravi Nanavati
-
Simon Marlow
-
Simon Peyton-Jones