[GHC] #5998: GHCi's :info to return all the visible instances, not just the ones imported from currently loaded files

GHC cvs-ghc at haskell.org
Thu Apr 26 15:22:44 CEST 2012


#5998: GHCi's :info to return all the visible instances, not just the ones
imported from currently loaded files
---------------------------------+------------------------------------------
    Reporter:  errge             |       Owner:                  
        Type:  feature request   |      Status:  new             
    Priority:  normal            |   Milestone:  7.6.1           
   Component:  GHCi              |     Version:  7.4.1           
    Keywords:  ghci :info        |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

  * milestone:  => 7.6.1


Comment:

 Simon and I discussed this.  Bottom line: it's hard to get a preditable
 semantics for displaying instances, so we propose to do nothing for now.
 Details follow.

  * GHC reads interface files (from packages) only on demand.
  * Only when GHC reads M's interface file will M's instances be known to
 GHC.

 So if module `M` from package `mypkg` contains
 {{{
   module M where
     data TX = Yes | No deriving( Show )
 }}}
 then when you say `:info Show` you will never see the `instance Show TX`
 unless GHC has some reason to read `M.hi`.

 What is that reason?
  * You say `:m M` to GHCi
  * Some typechecking activity required the definition of `TX`.

 Currently it is even possible fot `TX` to be in scope without `M.hi` being
 read:
 {{{
   module Indirect( TX ) where
     import M
 }}}
 Now if you go `:m Indirect`, GHC will read `Indirect.hi` but not `M.hi`.
 Doubtless this could be changed, so that in GHCi you could be sure that
 everything in scope refers to an interface file that has been loaded.

 But what about things NOT in scope.  What if `M` was deeply buried in a
 package, that had played no role in the current GHCi session? Do you want
 to see the instances then?  Even with the proposed `:info!`?  Does it
 matter that if you said `:info M.TX` and '''then''' asked for `:info!
 Show` you would get the Show instance, but not before said `:info M.TX`?

 Sigh.  Since it's not clear what we even want, it's not clear what change
 to make.  Hence parking this one pending more
 feedback/clarification/proposals.  I'll milestone it for 7.6.1, to make us
 look at it again, but it looks likely to sink  unless someone really
 cares.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5998#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list