What does [safe] marker mean in ghci?

对着背影说爱祢 提交于 2019-12-01 02:29:47

问题


Prelude Data.Void> :info Void
data Void       -- Defined in `Data.Void'
instance [safe] Eq Void -- Defined in `Data.Void'
instance [safe] Ord Void -- Defined in `Data.Void'
instance [safe] Read Void -- Defined in `Data.Void'
instance [safe] Show Void -- Defined in `Data.Void'

What does [safe] mean?


回答1:


It simply means that the datatype is defined in a module which is defined using safe extension. You can find the details of the extension in the user guide.

In fact, you can test that yourself by defining a module using the Safe extension:

{-#LANGUAGE Safe#-}

data Test = Test deriving (Eq, Show)

And then trying it out in ghci:

λ> :i Test
data Test = Test    
instance [safe] Eq Test 
instance [safe] Show Test 

But note that in the current GHC (7.10.2), the safe extension cannot be relied of the trust guarantee because of this ghc bug.



来源:https://stackoverflow.com/questions/33464076/what-does-safe-marker-mean-in-ghci

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!