Make XNoMonomorphismRestriction the default in GHCi
While it has been a subject of debate whether the Monomorphism Restriction is helpful in compiled code, it is quite clear that MR is a major annoyance, if not a bug, at the GHCi prompt.
MR at the GHCi prompt makes it inconvenient
to define functions using let
at the prompt. It also
unexpectedly assigns monomorphic types to
expressions entered interactively by the user -
in particular when it types numeric constants
as Integer
when the user needs an Int
.
None of the purported benefits of MR are relevant in GHCi. The kinds of problems that MR might help avoid are unlikely to arise during an interactive session, since the structure of functions entered at the prompt is on average far less complex than functions in source files. Any problems that do arise will become clear as the interactive session continues - likely with a clearer error message (in my personal experience).
MR at the GHCi prompt is one of the most confusing aspects of GHCi for inexperienced users, as evidenced by constant traffic on haskell-cafe and #haskell.
Disabling MR at the GHCi prompt would
not be a disruptive change. It would not
change the meaning of any program.
It would improve the GHCi workflow of
inexperienced users, and probably most
experienced users. If there are any
experienced users who feel that this
change disrupts their workflow, they can
easily revert to the current behavior
by adding a single line to their .ghci
file.
For reference, here is a long discussion about MR that took place on haskell-cafe a few years ago:
http://www.haskell.org/pipermail/haskell-prime/2006-January/000038.html
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |