看看Type是ghci的实例的哪个Typeclass? [英] See which Typeclasses the Type is an instance of in ghci?
本文介绍了看看Type是ghci的实例的哪个Typeclass?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以查看该类型实现的类型类?像这样:
Is it possible to see which typeclasses the type implements? Something like:
>:typeclasses Int
[Num, etc...]
推荐答案
使用:info
命令.
Prelude> :info Int
data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in GHC.Types
instance Bounded Int -- Defined in GHC.Enum
instance Enum Int -- Defined in GHC.Enum
instance Eq Int -- Defined in GHC.Base
instance Integral Int -- Defined in GHC.Real
instance Num Int -- Defined in GHC.Num
instance Ord Int -- Defined in GHC.Base
instance Read Int -- Defined in GHC.Read
instance Real Int -- Defined in GHC.Real
instance Show Int -- Defined in GHC.Show
自然地,此列表取决于当前导入的模块.
Naturally this list depends on the modules that are currently imported.
Prelude> :info (->)
data (->) a b -- Defined in GHC.Prim
Prelude> :m +Control.Monad.Instances
Prelude Control.Monad.Instances> :info (->)
data (->) a b -- Defined in GHC.Prim
instance Monad ((->) r) -- Defined in Control.Monad.Instances
instance Functor ((->) r) -- Defined in Control.Monad.Instances
这篇关于看看Type是ghci的实例的哪个Typeclass?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文