[GHC] #11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- After #11549, we are suppose not to show `RuntimeRep` to users, when `-fno-print-explicit-runtime-reps` is on. But we do: {{{ :info ($) Prelude> :i ($) ($) :: forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b -- Defined in ‘GHC.Base’ }}} This happens because the runtime-rep-suppression happens on `Type`, but for `:info` we use `pprInfo` which uses `tyThingToIfaceDecl` and then prints it. And `tyThingToIfaceDecl` doesn't know about the `-fprint- explicit-runtime-reps` flag; and I'd like to keep it that way. We want to change `pprType` to convert to `IfaceType` and then print anyway. I suppose that this means that the pretty-printer for `IfaceType` needs to know about this runtime-rep suppression. That's a bit tiresome, but not impossible, especially since there is no shadowing to worry about. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Indeed, since * we want `:type` do do deep-instantiation (#11376), and * I think we don't generalise over `RuntimeRep` variables, the ''only'' time `-fno-print-explicit-runtime-reps` now has an effect (except perhaps in debug output) is in `:info`; and that is precisely when it doesn't work! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Test T11549 demonstrates this -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep
leaks
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): For the record: The transition away from the `Type` pretty-printer to `IFaceType` is being tracked as #11660. I have a patch in progress for this, although have lacked time to finish it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 Comment: This has been fixed along with #11660. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sighingnow): This bug still exists in ghc-HEAD. With or without `:set -fprint-explicit-runtime-reps`, we both have {{{#!hs Prelude> :t ($) ($) :: (a -> b) -> a -> b Prelude> :i ($) ($) :: forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b -- Defined in ‘GHC.Base’ infixr 0 $ }}} This behavior is inconsistent with the description in user guide: https://downloads.haskell.org/~ghc/master/users-guide/using.html#ghc-flag --fprint-explicit-runtime-reps -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * priority: normal => highest * status: closed => new * resolution: fixed => * milestone: 8.2.1 => 8.6.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => LevityPolymorphism * related: => #13275, #15181 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Hmm, interesting. I wonder what regressed; the logic to instantiate runtime-reps certainly exists (see `IfaceType.defaultRuntimeRepVars`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

OK, well we can both live with
* `:type var` prints the original type of `var`, whereas `:type expr` typechecks, instantiates, and re-generalises the type of `expr`.
But how long will it be until someone posts a bug report complaining
#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: sighingnow Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sighingnow): * owner: (none) => sighingnow Comment: I have looked into this ticket. This `:set -fprint-explicit-runtime-reps` **doesn't** work in ghc 8.0.1/8.0.2/8.2.2/8.4.2/head. ------------------------------------------------- In IfaceType.hs, we use `pprIfaceSigmaType` to pretty print a type: {{{#!hs pprIfaceSigmaType :: ShowForAllFlag -> IfaceType -> SDoc pprIfaceSigmaType show_forall ty = ppr_iface_forall_part show_forall tvs theta (ppr tau) where (tvs, theta, tau) = splitIfaceSigmaTy ty }}} The kind signatures are not feed into `eliminateRuntimeRep` and `defaultRuntimeRepVars`. The `forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r)` is pretty printed by `pprUserIfaceForAll` (invoked by `ppr_iface_forall_part`). {{{#!hs pprUserIfaceForAll :: [IfaceForAllBndr] -> SDoc pprUserIfaceForAll tvs = sdocWithDynFlags $ \dflags -> -- See Note [When to print foralls] ppWhen (any tv_has_kind_var tvs || any tv_is_required tvs || gopt Opt_PrintExplicitForalls dflags) $ pprIfaceForAll tvs where tv_has_kind_var (TvBndr (_,kind) _) = not (ifTypeIsVarFree kind) tv_is_required = isVisibleArgFlag . binderArgFlag }}} So, for `($)`, we always print `($) :: forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r) (a -> b) -> a -> b`. ----------------------------------------- As for why `:t` and `:i` print different result, in f2a2b79fa8d1c702b17e195a70734b06625e0153, we instantiate deeply for `:type`, then `:t` and `:i` have different behaviour for `($)`. If we revert this commit, `:t ($)` will produce same result as `:i ($)`. ------------------------------------------------ In ticket:11376#comment:34, Simon wrote: that `:t (blah)` is different from `:t blah`?
Maybe not long, but we can just point to the user manual. Having two
commands is a pain when you can get the second by adding parens to the first.
Now we just need someone to do it.
I will try this and optimistically assign this ticket to myself. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: sighingnow Type: bug | Status: patch Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Changes (by sighingnow): * status: new => patch * differential: => Phab:D4733 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: sighingnow Type: bug | Status: patch Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Comment (by sighingnow): I have just noticed that ticket:11376#comment:34 has already been implemented by Phab:2136, via :type +v. I have revised Phab:D4733 to fix `-fprint-explicit-runtime-reps` only. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep
leaks
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: sighingnow
Type: bug | Status: patch
Priority: highest | Milestone: 8.6.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
| LevityPolymorphism
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: sighingnow Type: bug | Status: closed Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * owner: sighingnow => (none) * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Yikes. I have just wasted 30 minutes (in Core dumps) figuring out why a type printed as {{{ forall a b. Eq a => blah }}} didn't match a term {{{ /\ a. \(d :: Eq a). blah }}} Turns out that the real type is `forall a. Eq a => forall b. blah`, but the pretty printer silently moves the foralls to the top. This is done in `splitIfaceSigmaTy` in the patch in comment:13. It might be ''just'' arguable to move the foralls around for ''user'' types. E.g in test `ghci025` we now report {{{ return :: Monad m => a -> m a }}} whereas previously it was {{{ return :: Monad m => forall a. a -> m a }}} But we definitely should not do this in Core printouts. I also noticed that in the output for `ghci025` we have {{{ c3 :: forall a b a. C a b => a -> b }}} The repeated 'a' is terrible! So I'm re-opening this ticket to ask: do we want to swizzle the foralls to the top, even in user printout? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Another oddity is that `elminiateRunTimeRep` (which works recursively) is called by `pprIfaceSigmaTy`, which is called from `ppr_sigma` which is called by `ppr_ty` which is also recursive. This can't be right. I think `eliminateRuntimeRep` should only be called at top level -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11786: Need -fno-print-explicit-runtime-reps to work on IfaceType, else RuntimeRep leaks -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.6.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13275, #15181 | Differential Rev(s): Phab:D4733 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => fixed Comment: It seems a new ticket makes more sense: #16320. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11786#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC