在ghci,我声明一个数据类型如下.
data Example = MakeExample deriving Show
Run Code Online (Sandbox Code Playgroud)
然后,当我调用:info Example以查看派生Show实例被识别时,我得到以下输出.
> :i Example
data Example = MakeExample -- Defined at <interactive>:17:1
instance [safe] Show Example -- Defined at <interactive>:17:37
Run Code Online (Sandbox Code Playgroud)
该Show实例被认为是预期的.但是,我不明白为什么[safe]会这样.
相比之下,[safe]当我打电话不会出现:info上Bool.
> :i Bool
data Bool = False | True -- Defined in ‘GHC.Types’
instance Bounded Bool -- Defined in ‘GHC.Enum’
instance Enum Bool -- Defined in ‘GHC.Enum’
instance Eq Bool -- Defined in ‘GHC.Classes’
instance Ord Bool -- Defined in ‘GHC.Classes’
instance Read Bool -- Defined in ‘GHC.Read’
instance Show Bool -- Defined in ‘GHC.Show’
Run Code Online (Sandbox Code Playgroud)
什么是instance [safe]平均ghci的:info输出?