have ghci list all possible type class instances?

后端 未结 1 734
旧巷少年郎
旧巷少年郎 2021-01-17 17:21

When ghc can\'t determine a concrete type class instance, you\'ll get a message like:

No instance for ...
  arising from a use of `it\'
The type variable `a0         


        
1条回答
  •  时光说笑
    2021-01-17 18:03

    You can use the :info command (shortened to :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’
    

    0 讨论(0)
提交回复
热议问题