GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:02:24Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/15931MonoLocalBinds + MonomorphismRestriction prevents generalization for a top le...2019-07-07T18:02:24ZVarun GandhiMonoLocalBinds + MonomorphismRestriction prevents generalization for a top level definitionConsider the following code sample
```haskell
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE MonomorphismRestriction #-}
tmp = 10
picker x y = if tmp > 11 then x else y
main = do
print (picker "x" "y")
print (picker 10 11)
```
It fai...Consider the following code sample
```haskell
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE MonomorphismRestriction #-}
tmp = 10
picker x y = if tmp > 11 then x else y
main = do
print (picker "x" "y")
print (picker 10 11)
```
It fails with the misleading error message "\* No instance for (Num \[Char\]) arising from the literal \`10'...", from what seems to be an interaction between MonoLocalBinds and MonomorphismRestriction (turn either off and the error goes away).
Should this be happening only for local bindings, or is it correct for this error to occur for top-level definitions too?
In either case, would it be possible to give a better error message here?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | low |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"MonoLocalBinds + MonomorphismRestriction prevents generalization for a top level definition","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"⊥","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":["MonoLocalBinds,","MonomorphismRestriction"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider the following code sample\r\n\r\n{{{#!haskell\r\n{-# LANGUAGE MonoLocalBinds #-}\r\n{-# LANGUAGE MonomorphismRestriction #-}\r\ntmp = 10\r\npicker x y = if tmp > 11 then x else y\r\nmain = do\r\n print (picker \"x\" \"y\")\r\n print (picker 10 11)\r\n}}}\r\n\r\nIt fails with the misleading error message \"* No instance for (Num [Char]) arising from the literal `10'...\", from what seems to be an interaction between MonoLocalBinds and MonomorphismRestriction (turn either off and the error goes away).\r\n\r\nShould this be happening only for local bindings, or is it correct for this error to occur for top-level definitions too?\r\n\r\nIn either case, would it be possible to give a better error message here?","type_of_failure":"OtherFailure","blocking":[]} -->⊥