是否可以查看该类型实现了哪些类型类?类似于:
>:typeclasses Int
[Num, etc...]
发布于 2012-02-18 05:32:49
使用: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
当然,这个列表取决于当前导入的模块。
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
https://stackoverflow.com/questions/9335694
复制相似问题