What does [safe] marker mean in ghci?

后端 未结 1 848
感动是毒
感动是毒 2021-01-12 14:19
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         


        
相关标签:
1条回答
  • 2021-01-12 14:51

    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.

    0 讨论(0)
提交回复
热议问题