[GHC] #11549: Add -fshow-runtime-rep

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 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: -------------------------------------+------------------------------------- As discussed in several interwoven threads ([https://mail.haskell.org/pipermail/ghc-devs/2016-February/011268.html original], [https://mail.haskell.org/pipermail/haskell- cafe/2016-February/122914.html café]), it has been suggested to add a flag `-fshow-runtime-rep`. Without this flag enabled, the pretty printer will instantiate any `RuntimeRep` type parameters to `PtrRep Lifted`. This has the effect of changing {{{ ($) :: forall (r :: RuntimeRep) (a :: *) (b :: TYPE r). (a -> b) -> a -> b }}} to {{{ ($) :: (a -> b) -> a -> b }}} under the default GHCi settings. Note that `Levity` becomes `RuntimeRep` after #11471 is complete. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 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 RyanGlScott): One thing isn't clear to me about how `-fshow-runtime-rep` works. I'm assuming that without `-fshow-runtime-rep` on, you won't see any mention of `RuntimeRep` in error messages. If so, what kind of error would this produce? {{{#!hs import GHC.Exts bad :: forall (w :: RuntimeRep) (a :: TYPE w). a -> Int bad _ = 42 }}} The error would probably mention the type signature of `bad`, but would it be truncated to `a -> Int` instead of the full shebang? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType 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 simonpj): * keywords: => TypeInType -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType 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): * cc: bgamari (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: patch Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D1961 Comment: I gave this a shot in Phab:D1961. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: patch Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): See #11660 for a probably better approach. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: patch Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): But #11660 seems orthogonal to this -- the general idea that is described in this ticket and the implementation in Phab:D1961 would still need to exist even after #11660. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: patch Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:6 goldfire]:
But #11660 seems orthogonal to this -- the general idea that is described in this ticket and the implementation in Phab:D1961 would still need to exist even after #11660.
Well, the implementation in Phab:D1961 would move from `Type` to `IfaceType`, and might look a bit different there. That's all I meant -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: goldfire
Type: bug | Status: patch
Priority: highest | Milestone: 8.0.1
Component: Compiler | Version: 8.1
Resolution: | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1961
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: Merged to `ghc-8.0` in 371608f1cdaf20c49eb6c5ec165b9eb08b745a89. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Do you think it's worth special-casing this kind of behavior with `-XTypeApplications` as well? Currently, it's quite easy to leak `RuntimeRep`: {{{ $ /opt/ghc/8.0.1/bin/ghci GHCi, version 8.0.0.20160324: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/ryanglscott/.ghci λ> :t undefined undefined :: GHC.Stack.Types.HasCallStack => a λ> :set -XTypeApplications λ> :t undefined @Int <interactive>:1:12: error: • Expected kind ‘GHC.Types.RuntimeRep’, but ‘Int’ has kind ‘*’ • In the type ‘Int’ In the expression: undefined @Int }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Mmm, this is a good point. My first thought here was to look for kind errors in specified type arguments and provide the user with a better error (including the full type of the applied function) in the case of a unification error. Austin and I discussed this and he suggested that perhaps `-XTypeApplications` should imply `-fprint-explicit-runtime-reps`. This sounds reasonable (if a bit surprising) at first glance given how likely it is that you will experience `RuntimeRep` arguments with `TypeApplications`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: closed => new * priority: highest => normal * resolution: fixed => * owner: goldfire => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * version: 8.1 => 8.0.1-rc2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.1 => 8.0.2 Comment: Unfortunately I don't see an easy way to make comment:11 happen. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Another problem: #11786 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.2 => 8.2.1 Comment: This won't be happening for 8.0.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: Nor will this happen for 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): While comment:10 is indeed an odd interaction, these sorts of problems become inevitable. I'm reminded of a scene in the movie Interstellar where a robot describes that his "honesty setting" is at 90%, because that just works out better than being 100% honest. As GHC's type system has become more complicated, users have been requesting it to lower its honesty setting, hiding bits and pieces that look scary. We now have `-fprint- explicit-kinds`, `-fprint-explicit-coercions`, `-fprint-explicit-foralls`, `-fprint-equality-relations`, and `-fprint-explicit-runtime-reps`. Each of these flags are off by default, and each one is essentially an honesty setting. Perhaps with the exception of `-fprint-explicit-coercions`, the fact that GHC lies about these aspects of a program means that programmers may make mistakes -- it's the old "garbage in, garbage out", but in reverse! (with the humans getting and producing the garbage) I don't know how to really solve this, short of #8809, which would lead to Idris-like interactivity in error messages. We could try to figure out when a user has produced garbage in response to a lie that GHC has told and then tell the user to tell GHC not to lie (as we do when we suggest `-fprint-explicit-kinds` in error messages), but I think we'll always be playing catch-up. Instead, we should give the user the direct option (via #8809) to know when GHC is lying and to request the truth. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: ⊥ Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.4.1 => ⊥ Comment: Removing milestone in light of comment:18. I think #8809 is ultimately the way forward here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11549: Add -fshow-runtime-rep -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1961 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => fixed Comment: Indeed, I think my suggestion in comment:10 is far too ambitious to be realistic (at least, at the moment). Moreover, `-fprint-explicit-runtime- reps` is now fully implemented and does the job that it advertises in the users' guide (namely, it prints `RuntimeRep`-polymorphic type variables in full detail), so I think this can be closed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11549#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC