Micha Wiedenmann
Micha Wiedenmann

Reputation: 20873

How to query the type of a default method?

The GHC extension DefaultSignatures allows to change the type of a default method:

class Enum a where
  enum :: [a]
  default enum :: (Generic a, GEnum (Rep a)) => [a]
  enum = map to genum

Is it possible to ask the compiler for the type of the default method? What is the syntax to do so? :t enum is not enough (since it obviously reports enum :: Enum a => [a]).

Upvotes: 3

Views: 51

Answers (1)

Isaac van Bakel
Isaac van Bakel

Reputation: 1862

:info Enum will do it.

For your example, this will produce the output

class Enum a where
  enum :: [a]
  default enum :: (Generic a, GEnum (Rep a)) => [a]
        -- Defined at ...

Upvotes: 3

Related Questions