Opened 12 years ago

Closed 11 years ago

Last modified 47 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: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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.
| / /_\\/ __  / /___| |
| \____/\/ /_/\____/|_|      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 
| instance Enum Bool 	-- Imported from 
| 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 12 years ago by remit

Logged In: YES 

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.

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

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

-- 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,
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 11 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 

I've finally fixed this properly.

Note: See TracTickets for help on using tickets.