|
|
# Lift the monomorphism restriction
|
|
# Lift the monomorphism restriction =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We could simply remove the M-R from the language, but suggest that implementations issue a warning when a loss of sharing might occur due to overloading of a variable or pattern binding.
|
|
We could simply remove the M-R from the language, but suggest that implementations issue a warning when a loss of sharing might occur due to overloading of a variable or pattern binding.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The warning would not be mandatory - the report doesn't mandate implementation behaviour of this kind, rather it would be a recommendation. To make the warning mandatory would require talking about operational semantics, which the report also doesn't do.
|
|
The warning would not be mandatory - the report doesn't mandate implementation behaviour of this kind, rather it would be a recommendation. To make the warning mandatory would require talking about operational semantics, which the report also doesn't do.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**For:**
|
|
**For:**
|
|
|
|
|
|
|
|
|
|
|
|
- Simple, removes a wart from the language
|
|
- Simple, removes a wart from the language
|
|
|
- "As much polymorphism as possible" is in the spirit of Haskell - it is strange to limit polymorphism for performance reasons (indeed, this is arguably a poor compromise)
|
|
- "As much polymorphism as possible" is in the spirit of Haskell - it is strange to limit polymorphism for performance reasons (indeed, this is arguably a poor compromise)
|
|
|
- It turns out to be quite hard to demonstrate a performance problem due to the M-R, at least with GHC, because its optimiser often recovers the sharing.
|
|
- It turns out to be quite hard to demonstrate a performance problem due to the M-R, at least with GHC, because its optimiser often recovers the sharing.
|
| ... | @@ -16,8 +21,10 @@ The warning would not be mandatory - the report doesn't mandate implementation b |
... | @@ -16,8 +21,10 @@ The warning would not be mandatory - the report doesn't mandate implementation b |
|
|
- Hugs has a different (non-Haskell98) implementation of the M-R
|
|
- Hugs has a different (non-Haskell98) implementation of the M-R
|
|
|
- Haskell doesn't specify an evaluation strategy so introducing the concept of 'sharing' is strange indeed.
|
|
- Haskell doesn't specify an evaluation strategy so introducing the concept of 'sharing' is strange indeed.
|
|
|
|
|
|
|
|
|
|
|
|
**Against:**
|
|
**Against:**
|
|
|
|
|
|
|
|
|
|
|
|
- Might be hard to give an accurate warning; just warning about overloaded variable bindings isn't good enough, because they don't all result in loss of sharing.
|
|
- Might be hard to give an accurate warning; just warning about overloaded variable bindings isn't good enough, because they don't all result in loss of sharing.
|
|
|
- The warning might be confusing to new users (but if we could make it accurate, it wouldn't happen much)
|
|
- The warning might be confusing to new users (but if we could make it accurate, it wouldn't happen much)
|
|
|
- For cases where you want the polymorphic type and don't want to write a type signature, then having the compiler emit a warning by default is undesirable. |
|
- For cases where you want the polymorphic type and don't want to write a type signature, then having the compiler emit a warning by default is undesirable. |