[GHC] #11051: GHCi with +t option set shows type representations
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- hvr reported this morning that defining a data type in GHCi with the show types (`:set +t`) option set results in additional unexpected output. For instance, {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 7.11.20151101: http://www.haskell.org/ghc/ :? for help Prelude> :set +t Prelude> data Hi $tcHi :: TyCon $trModule :: Module data Hi Prelude> }}} The `$tcHi` and `$trModule` bindings are details of the Typeable implementation introduced in Phab:D1404 and should likely be hidden from the user. This would be trivial to fix except for the fact that we currently have no way to identify this sort of `Name`. In fact any knowledge that the name was generated appears to have been thrown away as early as `OccName.mkTyConRepSysOcc`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by bgamari: Old description:
hvr reported this morning that defining a data type in GHCi with the show types (`:set +t`) option set results in additional unexpected output. For instance,
{{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 7.11.20151101: http://www.haskell.org/ghc/ :? for help Prelude> :set +t Prelude> data Hi $tcHi :: TyCon $trModule :: Module data Hi Prelude> }}}
The `$tcHi` and `$trModule` bindings are details of the Typeable implementation introduced in Phab:D1404 and should likely be hidden from the user.
This would be trivial to fix except for the fact that we currently have no way to identify this sort of `Name`. In fact any knowledge that the name was generated appears to have been thrown away as early as `OccName.mkTyConRepSysOcc`.
New description: hvr reported this morning that defining a data type in GHCi with the show types (`:set +t`) option set results in additional unexpected output. For instance, {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 7.11.20151101: http://www.haskell.org/ghc/ :? for help Prelude> :set +t Prelude> data Hi $tcHi :: TyCon $trModule :: Module data Hi Prelude> }}} The `$tcHi` and `$trModule` bindings are details of the Typeable implementation introduced in Phab:D1404 and should likely be hidden from the user. This would be trivial to fix in `InteractiveUI.printTypeOfNames` except for the fact that we currently have no way to identify this sort of `Name`. In fact any knowledge that the name was generated appears to have been thrown away as early as `OccName.mkTyConRepSysOcc`. -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * owner: => bgamari -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): As it turns out generic deriving is also bitten by this, {{{ GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help λ> :set +t λ> :set -XDeriveGeneric λ> import GHC.Generics λ> data Hello = Hello Int deriving (Eq, Generic) abstract C1_0Hello abstract D1Hello data Hello = Hello Int abstract S1_0_0Hello }}} For the record, `hscDeclsWithLocation` in `HscMain` is responsible for the evaluation and generation of `TyThings`. Currently it drops `TyThings` corresponding to implicit `TyCons`/`Ids` and `DFunIds`, {{{#!hs let tcs = filterOut isImplicitTyCon (mg_tcs simpl_mg) patsyns = mg_patsyns simpl_mg ext_ids = [ id | id <- bindersOfBinds core_binds , isExternalName (idName id) , not (isDFunId id || isImplicitId id) ] -- We only need to keep around the external bindings -- (as decided by TidyPgm), since those are the only ones -- that might later be looked up by name. But we can exclude -- - DFunIds, which are in 'cls_insts' (see Note [ic_tythings] in HscTypes -- - Implicit Ids, which are implicit in tcs -- c.f. TcRnDriver.runTcInteractive, which reconstructs the TypeEnv }}} This would be one place to drop the bindings covered by this ticket. However, in order to do this we need to find a way to encode the fact that the bindings are generated. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): I wonder if this is related to #11328 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): My guess is that we'd want to do something like this to ensure that `System` names never make it to the user. {{{#!patch diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 013be3c..d3020d7 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -235,8 +235,9 @@ runStmtWithLocation source linenumber expr step = do runDecls :: GhcMonad m => String -> m [Name] runDecls = runDeclsWithLocation "<interactive>" 1 -runDeclsWithLocation - :: GhcMonad m => String -> Int -> String -> m [Name] +-- | Run some declarations and return any user-visible names that were brought +-- into scope. +runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name] runDeclsWithLocation source linenumber expr = do hsc_env <- getSession @@ -246,7 +247,13 @@ runDeclsWithLocation source linenumber expr = hsc_env <- getSession hsc_env' <- liftIO $ rttiEnvironment hsc_env modifySession (\_ -> hsc_env') - return (map getName tyThings) + + -- Trac #11051: We filter out system names since the user is not interested + -- in them. These include, + -- * Data family tycons from, e.g., derived Generic instances + -- * Type representation (Typeable) definitions (e.g. $trMyModule) + -- * others + return $ filter (not . isSystemName) $ map getName tyThings }}} With this we've reduced the problem to ensuring that the generated Typeable identifiers get marked as `System` names. Currently they are conjured by up `IfaceEnv.newGlobalBinder` which only knows how to produce `External` names. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): One of the reasons this seems to be so tricky is that `NameSort` conflates a few concerns, * Is the name given to us by the user or provided by the compiler (e.g. `WiredIn`)? * Is the name usable outside of the current module (`External` and `Internal`)? * Should the name be shown to the user (e.g. `System`)? It's not entirely clear to me when this various constructors are being used to represent what points in this space. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.0.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * priority: high => normal * milestone: 8.0.1 => Comment: The right thing is `isDerivedOccName`. I'm working on this. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * owner: bgamari => simonpj -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high * milestone: => 8.0.1 Comment: We should really aim to get this fixed for 8.0.1. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"ec8a188a927a4db2e709541765e5ef545eae284c/ghc" ec8a188a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="ec8a188a927a4db2e709541765e5ef545eae284c" Refactoring on IdInfo and system derived names Some modest refactoring, triggered in part by Trac #11051 * Kill off PatSynId, ReflectionId in IdDetails They were barely used, and only for pretty-printing * Add helper function Id.mkExportedVanillaId, and use it * Polish up OccName.isDerivedOccName, as a predicate for definitions generated internally by GHC, which we might not want to show to the user. * Kill off unused OccName.mkDerivedTyConOcc * Shorten the derived OccNames for newtype and data instance axioms * A bit of related refactoring around newFamInstAxiomName }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): OK, Ben, is `isDerivedOccName` now enough to let you solve this? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I believe so. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: simonpj Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1794 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D1794 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1794 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * owner: simonpj => bgamari -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:16> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1794 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"d2ea7f94cb21662857cd50c95ff41943e5911a9b/ghc" d2ea7f9/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="d2ea7f94cb21662857cd50c95ff41943e5911a9b" Hide derived OccNames from user This hides derived OccNames from the Names returned from runDeclsWithLocation and clarifies the documentation. This is done to ensure that these names (originating from, e.g., derived Generic instances and type representation bindings) don't show up in ghci output when run with `:set +t`. This fixes #11051. Test Plan: Validate with included tests Reviewers: austin Reviewed By: austin Subscribers: thomie, hvr Differential Revision: https://phabricator.haskell.org/D1794 GHC Trac Issues: #11051 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:17> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1794 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: Merged to `master` and `ghc-8.0` (as d2ea7f94cb21662857cd50c95ff41943e5911a9b). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:18> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11051: GHCi with +t option set shows type representations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1794 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"e604e916a9727a22a392062096ea947df5fbe2c6/ghc" e604e91/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="e604e916a9727a22a392062096ea947df5fbe2c6" Comments only Re Trac #11051 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11051#comment:19> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC