Is there a ghci list for all types of class instances?

When ghc cannot determine a specific instance of a type class, you will receive a message of the type:

No instance for ... arising from a use of `it' The type variable `a0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: (lists a few instances) ...plus 13 others Possible fix: ... 

Is there a way to display all specific instances of a type class?

+7
haskell typeclass ghci
source share
1 answer

You can use the command :info (short for :i ) to do this:

 > :i Num class Num a where (+) :: a -> a -> a (*) :: a -> a -> a (-) :: a -> a -> a negate :: a -> a abs :: a -> a signum :: a -> a fromInteger :: Integer -> a -- Defined in 'GHC.Num' instance Num Integer -- Defined in 'GHC.Num' instance Num Int -- Defined in 'GHC.Num' instance Num Float -- Defined in 'GHC.Float' instance Num Double -- Defined in 'GHC.Float' 
+8
source share

All Articles