Opened 9 years ago

Closed 9 years ago

Last modified 44 years ago

#333 closed bug (Fixed)

GHCi reports too few instances

Reported by: simonpj Owned by: nobody
Priority: low Milestone:
Component: GHCi Version: None
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

GHCi aspires to report all instances that can be written 
unqualified in the current scope; but it doesn't.


| ~% ghci
|    ___         ___ _
|   / _ \ /\  /\/ __(_)
|  / /_\// /_/ / /  | |      GHC Interactive, version 6.4, for 
Haskell 98.
| / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
| \____/\/ /_/\____/|_|      Type :? for help.
| 
| Loading package base-1.0 ... linking ... done.
| 
| Prelude> :i Bool
| data Bool = False | True 	-- <wired into compiler>
| instance Eq Bool 	-- Imported from GHC.Base
| instance Ord Bool 	-- Imported from GHC.Base
| 
| Prelude> :i Bool
| data Bool = False | True 	-- <wired into compiler>
| instance Bounded Bool 	-- Imported from 
GHC.Enum
| instance Enum Bool 	-- Imported from 
GHC.Enum
| instance Eq Bool 	-- Imported from GHC.Base
| instance Ord Bool 	-- Imported from GHC.Base
| instance Read Bool 	-- Imported from GHC.Read
| instance Show Bool 	-- Imported from GHC.Show

Change History (2)

comment:1 Changed 9 years ago by remit

Logged In: YES 
user_id=26642

Though it's (they are) probably not strictly the same bug,
I'll report them here as they're definitely related, and I
suspect they'll someday be fixed all at once.

-----------------

First, GHCi's :info doesn't seem to show any instances of
function types. That is, instances like the following are
never shown by an :info.

instance Arrow (->)
instance Monad ((->) r)
instance Num b => Num (a -> b)

instance Foo (Bar (->)) and variants are shown, however.

-----------------

Second, though it's more a (very low priority) feature
request than a bugreport, it would be nice if ":info (->)"
and variants would work.

-----------------

Then, modules first loaded, then removed again in GHCi leave
their instances behind:

Prelude> :module +Control.Monad.Reader
Prelude Control.Monad.Reader> return 42 $ 0 
Loading package mtl-1.0 ... linking ... done.
42

-- okay, instance Monad (r->) is in scope

Prelude Control.Monad.Reader> :module -Control.Monad.Reader
Prelude> return 42 $ 0 
42

-- and stil is... Both in 6.4 and 6.2.1, at least.

-----------------

Finally, just to make this bug-report a bit more complete,
I'll copypaste a documented bug from
http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs.html#bugs-ghci,
which I /think/ is not exactly the same as the previous one.

"GHCi does not keep careful track of what instance
declarations are 'in scope' if they come from other
packages. Instead, all instance declarations that GHC has
seen in other packages are all in scope everywhere, whether
or not the module from that package is used by the
command-line expression"

comment:2 Changed 9 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 
user_id=50165

I've finally fixed this properly.

Simon
Note: See TracTickets for help on using tickets.