[Haskell-cafe] Is it possible to print out types of instances in scope

Lemmih lemmih at gmail.com
Sun Jan 16 06:09:43 EST 2005


On Sun, 16 Jan 2005 00:13:08 -0800, Jeremy Shaw
<jeremy.shaw at linspireinc.com> wrote:
> Hello,
> 
> Is it possible to write a function that would display all the instances
> of a class currently in scope[1]?
> 
> For example, for 'Show a' it should output something like:
> 
> The instances of 'Show a' currently in scope are:
> Show Int
> Show Float
> Show Char
> Show ...

In GHC 6.3:
Prelude> :i Show
class Show a where
  showsPrec :: Int -> a -> String -> String
  show :: a -> String
  showList :: [a] -> String -> String
-- Imported from `GHC.Show'
instance Show IOMode    -- Imported from `GHC.IOBase'
instance Show IOException       -- Imported from `GHC.IOBase'
instance Show IOErrorType       -- Imported from `GHC.IOBase'
instance Show HandleType        -- Imported from `GHC.IOBase'
[...]

-- 
Friendly,
  Lemmih


More information about the Haskell-Cafe mailing list