[GHC] #10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Keywords: newcomer | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Compare {{{ rwbarton@morphism:/tmp$ ghci-7.10.1 -XMonomorphismRestriction GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help Prelude> let a = (+) Prelude> :t a a :: Num a => a -> a -> a }}} with {{{ rwbarton@morphism:/tmp$ ghci-7.10.1 GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help Prelude> :set -XMonomorphismRestriction Prelude> let a = (+) Prelude> :t a a :: Integer -> Integer -> Integer }}} Confusing! This also occurred in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * related: => #3202, #3217 Comment: `ghci -XNoExtendedDefaultRules` does't turn off `ExtendedDefaultRules` either: {{{ Prelude> :showi language base language is: Haskell2010 with the following modifiers: -XNoDatatypeContexts -XExtendedDefaultRules -XNoMonomorphismRestriction -XNondecreasingIndentation }}} This seems to be by design. From https://ghc.haskell.org/trac/ghc/ticket/3217#comment:15: The DynFlags used to compile code will be computed as follows. ... When compiling an expression typed on the GHCi command line: * Start with the baseline DynFlags * Apply flags specified on the original command-line * (Perhaps: apply flags specified by :set in this GHCi session. We aren't sure whether or not to do this.) * Apply GHCi baseline command-prompt flags (e.g. special defaulting rules) * Apply flags specified by :seti in this GHCi session * If there is a fully-open module M, apply flags specified in M itself. That is, flags in M get the last word. I agree it is confusing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): That ''is'' confusing! What about putting (4) immediately after (1), so that it can be modified by command line or :set commands? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by cocreature): * owner: => cocreature -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by cocreature): Hey, I looked into this and it turns out it's actually not that easy to move it to an earlier point because those options should be in the interactive DynFlags which we set only after we have overwritten the DynFlags using the command line arguments. Now there is an easy solution which consists of just putting it in the standard DynFlags instead of the interactive ones. In fact we already do this for [https://github.com/ghc/ghc/blob/master/ghc/Main.hs#L182 another flag]. This works just fine but obviously some tests fail now since it is now not limited to the interactive flags. The other option is to set all of the interactive DynFlags earlier, but it looks like we then need to have two different set of flags, modify both of them by the command line arguments and then set them. This does not seem like a very nice solution either. If you are okay with putting it not in the interactive dynflags, then that's definitely the easiest solution, but as I am not really happy with that myself I'll think about it a bit more and try to come up with a less hacky solution. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): Which tests fail if you add `-XNoMonomorphismRestriction` to the standard DynFlags? You linked to `-fimplicit-import-qualified` being added to the standard DynFlags. I see there is a TODO (XXX) there, so it looks like this is considered to be a bug. But I'm having trouble coming with an example that would trigger the bug, can you? I tried the following, expecting it to be erroneously accepted by GHCi (when running `ghci Test.hs`), but it isn't: Test.hs: {{{ main = print $ Data.List.foldl' (+) 0 [1,2,3] }}} This fails with `error: Not in scope: ‘Data.List.foldl'’`. So now I don't understand the difference between the standard DynFlags and the interactive DynFlags. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by cocreature): The tests that fail are {{{ make TEST="dynbrk002 break021 break012 print012 break020 ghci057 T9293 ghci024 ghci058" }}} and here's the [http://lpaste.net/141427 output]. One reason for the failure is that :show language shows the extensions whereas atm only :showi language shows them. The other failures seem to be related to the ghci debugger printing some type signatures differently which is probably related to {{{-XExtendedDefaultRules and}}} {{{-XNoMonomorphismRestriction}}} now appearing outside of the interactive session flags as well. Apart from the debugger case I feel like it's mostly a semantic distinction. Your code doesn't fail because the hack only adds {{{-fimplicit-import- qualified}}} to the DynFlags if load mode is {{{DoInteractive}}} or {{{DoEval}}}. I haven't managed to come up with anything that triggers the bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): {{{ +[1 of 1] Compiling Ghci058 ( Ghci058.hs, interpreted ) [flags changed] Ok, modules loaded: Ghci058. }}} That's unacceptable I think. After compiling a module with `-dynamic`, and then loading it in GHCi, GHCi shouldn't have to reinterpret it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: cocreature Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): Replying to [comment:6 cocreature]:
Your code doesn't fail because the hack only adds {{{-fimplicit-import- qualified}}} to the DynFlags if load mode is {{{DoInteractive}}} or {{{DoEval}}}.
But when I run `ghci`, isn't the load mode always `DoInteractive`? So shouldn't `-fimplicit-import-qualified` also apply to modules loaded into GHCi, as in my example? I guess it doesn't, but I don't understand why not. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by cocreature): * owner: cocreature => Comment: I can't come up with a nice solution to this, I'll leave it to someone else. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * keywords: newcomer => Comment: This might be tricky, and not much fun. Removing newcomers keyword. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #3202, #3217 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: (none) => RolandSenn * milestone: => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TESTS="T10857a T10857b" Blocked By: | Blocking: Related Tickets: #3202, #3217, | Differential Rev(s): Phab:D5444 #14551 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * testcase: => make test TESTS="T10857a T10857b" * status: new => patch * differential: => Phab:D5444 * related: #3202, #3217 => #3202, #3217, #14551 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TESTS="T10857a T10857b" Blocked By: | Blocking: Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge #14551 | Request 34 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * differential: Phab:D5444 => Gitlab Merge Request 34 Comment: Moved patch from Phabricator to Gitlab. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TESTS="T10857a T10857b" Blocked By: | Blocking: Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge #14551 | Request 35 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * differential: Gitlab Merge Request 34 => Gitlab Merge Request 35 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism
restriction
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: RolandSenn
Type: bug | Status: patch
Priority: normal | Milestone: 8.8.1
Component: GHCi | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: make test
| TESTS="T10857a T10857b"
Blocked By: | Blocking:
Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge
#14551 | Request 35
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism
restriction
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: RolandSenn
Type: bug | Status: patch
Priority: normal | Milestone: 8.8.1
Component: GHCi | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: make test
| TESTS="T10857a T10857b"
Blocked By: | Blocking:
Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge
#14551 | Request 35
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TESTS="T10857a T10857b" Blocked By: | Blocking: Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge #14551 | Request 35 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Fixed in #10857. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10857: "ghci -XMonomorphismRestriction" doesn't turn on the monomorphism restriction -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: RolandSenn Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 7.10.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TESTS="T10857a T10857b" Blocked By: | Blocking: Related Tickets: #3202, #3217, | Differential Rev(s): Gitlab Merge #14551 | Request 35 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10857#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC