9
votes

In ghci you can run the :info command to learn about the methods defined on a type class, as well as see instances of that type class.

For example, :info Eq outputs

class Eq a where
  (==) :: a -> a -> Bool
  (/=) :: a -> a -> Bool
    -- Defined in `GHC.Classes'

as well as many lines of the instances

instance (Eq k, Eq a) => Eq (Map k a)
  -- Defined in `containers-0.5.0.0:Data.Map.Base'
instance Eq a => Eq (Maybe a) -- Defined in `Data.Maybe'
...

Is there a way, in ghci, to just output the methods defined in the type class without also outputting all the instances? In other words, I would like a ghci command to output only this:

class Eq a where
  (==) :: a -> a -> Bool
  (/=) :: a -> a -> Bool
    -- Defined in `GHC.Classes'
1
Nope. Sorry about that. If there's some larger problem you're trying to solve with this request, maybe there's another way to solve it we can help you with. - luqui
Thanks. Really, I just wanted more control over the output of :info. There are often many instances, and sometimes it's hard to find the class information among all the outputs. I'll mark a "no" answer as correct, if you want to submit an answer. - apolune

1 Answers

3
votes

No, unfortunately. :-/

No you cannot have an answer under 30 characters.