
Am 01.11.21 um 06:10 schrieb Viktor Dukhovni:
On Mon, Nov 01, 2021 at 12:54:47AM -0400, David Feuer wrote:
It would silently change behavior of some programs, yes. It could also make them slower under some circumstances. But anyone relying on the monomorphism restriction to choose types for their program should change their ways regardless. Top level type signatures aren't that hard to write.
It isn't just, or even primarily top level signatures. It is more often let bindings that will lack a signature, and frankly I'd rather have the restriction in place.
When your type fails to generalise and code does not compile, the solution is not hard to find. When let-bound expressions cease to be CAFs, and start being evaluated repeatedly, rather than just once, that's substantially harder to find and diagnose.
Good point. I have a question, since the wording in the Haskell 2010 Report is pretty complicated: Is it really guaranteed that a declaration of the form var = closed_expr (where closed_expr contains no free variables) without a type signature compiles to a CAF? I.e. is evaluated only once? Assuming this is is the case I admit there is justification for the MR. Other solutions are possible, though, for instance the compiler could issue a warning, ideally together with a hint that you may want to add a type signature to make your intention clear: either you want a CAF or the most general type; you can't have both. Cheers Ben -- I would rather have questions that cannot be answered, than answers that cannot be questioned. -- Richard Feynman