Quantcast

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

classic Classic list List threaded Threaded
7 messages Options
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
#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            |      Component:  GHCi            
  Version:  7.4.1             |       Keywords:  ghci :info      
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown      |       Testcase:                  
Blockedby:                    |       Blocking:                  
  Related:                    |  
------------------------------+---------------------------------------------
 Haskell report 5.4 says that instance visibility is transitively kept
 amongst module imports.

 So, if A imports B, B imports C, and inside C.hs I have instance Eq C, it
 is enough to import A in Main.hs to have the Eq C instance visible.  It is
 not required to import C directly.

 When I use the import chain, the compiler works correctly, but ghci :info
 Eq doesn't report C as an instance, only if I import C directly.

 This behavior is misleading, because if someone is not familiar with the
 specification, may believe after trying with :info that the instance is
 not transitively visible.

 I attached a test for this issue, after unpacking you can use demo.sh to
 demonstrate the issue.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
#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:                  
   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):

  * difficulty:  => Unknown


Comment:

 Currently this is by design: GHC only displays instances whose types have
 been brought into scope.  In this case module B does not export the type
 C, so C is not in scope in Main, so its instances are not displayed.

 This is a design choice (implemented in the `plausible` function in
 `InteractiveEval.getInfo`).  I'm not sure when we introduced it, or how
 persuasive the reasoning was at the time.  Changing it to display all
 instances would be easy; but then you might get `Eq` instantces displayed
 for zillions of types that you had no interest in.

 One could make other choices: eg display only for types in the current
 package, not for imported packages... I don't know what's best.  Opinions
 anyone?

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
In reply to this post by GHC
#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:                  
   Component:  GHCi              |     Version:  7.4.1          
    Keywords:  ghci :info        |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by errge):

 Good point, clarity is important too.  Especially for beginners, using
 ghci for the first time, I don't want to scare them :)

 How about a discrete message like this:
 -=-
 There are also 56234 other visible instances, not shown for clarity.
 -=-

 That would basically leave the experience as it is currently, but would
 have been enough for me to warn about the instances I were missing through
 my debugging session.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
In reply to this post by GHC
#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:                  
   Component:  GHCi              |     Version:  7.4.1          
    Keywords:  ghci :info        |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by simonmar):

 FYI, the commit that last changed this was

 commit b0d80aa3d908a6b9991920a5ac7fd1b437ecafd3
 {{{
 Author: [hidden email] <unknown>
 Date:   Sat Aug 4 17:35:39 2007 +0000

     In GHCi, filter instances by what is in scope, not just by what is in
 scope unqualified

     Trac #1581 was doing too much filtering; it even filtered out intances
     defined in this very module!  The new rule shows more instances, but
     hopefully not to many.
 }}}

 I like the suggestion in comment:2.  Maybe this:

 {{{
     -- 32 other instances exist, but involve types that are not in scope.
     -- Use :info! to see all instances.
 }}}

     Furthermore I have moved the filtering out of TcRnDriver (where it
 does
     not belong) to InteractiveEval. And I've added a note to the
 documentation.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
In reply to this post by GHC
#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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
In reply to this post by GHC
#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.2          
   Component:  GHCi              |     Version:  7.4.1          
    Keywords:  ghci :info        |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by diatchki):

 Hello,

 I hadn't seen this ticket but I run into exactly the same problem and
 implemented the ":info!" functionality, which simply shows all instances
 that GHCi currently knows about by simply disabling the filtering.  It
 seems to work reasonably well and avoids the extremely puzzling situation
 where we know that an instance is available because the methods work, but
 GHCi does not show the instance.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

GHC
In reply to this post by GHC
#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:  closed          
  Priority:  normal            |      Milestone:  7.6.2          
 Component:  GHCi              |        Version:  7.4.1          
Resolution:  fixed             |       Keywords:  ghci :info      
        Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown      |     Difficulty:  Unknown        
  Testcase:                    |      Blockedby:                  
  Blocking:                    |        Related:                  
-------------------------------+--------------------------------------------
Changes (by diatchki):

  * status:  new => closed
  * resolution:  => fixed


Comment:

 I have documented the new `:info!` functionality.  Just for future
 documentation, here is an example of the use case for this feature:

 In scope:
 {{{
    Accessor
    Applicateive
    instance Monoid Int
    instance Monoid m => Applicative (Accessor m)
 }}}
 Not in scope:
 {{{
    Monoid
 }}}
 With this setup, we can use the instance for `Applicateive (Accessor Int)`
 even though the name `Monoid` is not in scope, but `:info` will not show
 the relevant instance.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Loading...