我们可以在ghci中有一个简短的信息输出吗?

bas*_*ode 1 haskell ghci

有没有理由为什么:infoghci 的输出在它所属的每个类之后列出类型名称?例如

Prelude> :info Int` 
Run Code Online (Sandbox Code Playgroud)

版画

...
instance Bounded Int -- Defined in `GHC.Enum'
instance Enum Int -- Defined in `GHC.Enum'
instance Eq Int -- Defined in `GHC.Classes*emphasized text*'
...
Run Code Online (Sandbox Code Playgroud)

我更喜欢读的是:

Prelude> :info Int
...
instance Bounded -- Defined in `GHC.Enum'
instance Enum -- Defined in `GHC.Enum'
instance Eq -- Defined in `GHC.Classes*emphasized text*'
...
Run Code Online (Sandbox Code Playgroud)

甚至更好的是简短的表示法

Prelude> :info Int
...
instance of Bounded, Enum, Eq,...
Run Code Online (Sandbox Code Playgroud)

tho*_*ron 7

也许,一个原因是参数化类型.为了说明我的观点,请看这个例子:

$ ghci -XMultiParamTypeClasses -XFlexibleInstances
-- ...
Prelude> class Klass a b c where {f :: a b c -> c}
Prelude> data Typ b c = Typ b c
Prelude> instance Klass Typ b Integer where { f (Typ _ c) = c + 1 }
Prelude> let x = Typ "a" 3
Prelude> f x
4
Prelude> :info Typ
data Typ b c = Typ b c  -- Defined at <interactive>:3:6
instance Klass Typ b Integer -- Defined at <interactive>:4:10
Run Code Online (Sandbox Code Playgroud)