[GHC] #8827: Inferring Safe mode with GeneralizedNewtypeDeriving is wrong

GHC ghc-devs at haskell.org
Thu Mar 20 08:59:34 UTC 2014


#8827: Inferring Safe mode with GeneralizedNewtypeDeriving is wrong
-------------------------------------+------------------------------------
        Reporter:  goldfire          |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:  7.8.1
       Component:  Compiler          |          Version:  7.8.1-rc2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  8226, 8745
-------------------------------------+------------------------------------

Comment (by simonpj):

 `Coercible` is not a regular type class, and its "instances" are not
 subject to the usual rules of "always-exported".  So you can 100% ignore
 the rules for normal instances.

 The question is "under what circumstances are the instances of `Coercible`
 visible?".  Or, to make it sound less type-class-ish, you could ask "what
 rules are used to solve `Coercible` constraints?".

 Section 3 of the [http://research.microsoft.com/~simonpj/papers/ext-f
 paper] discusses this in some detail -- I hope everyone in this
 conversation has read it carefully. Specifically:

  * The "newtype-unwrapping" instance is available only if the newtype data
 constructor is visible.  This is uncontroversial, just what Safe Haskell
 wants, and is clearly not what a "normal instance" is like.

  * The "lifting" instances are controlled by roles.  And here there is
 room for debate about the proper defaults for those roles.  For example,
 we could say that with Safe Haskell the default roles (ie if you don't
 give an explicit signature) of any data type declared in that module are
 nominal rather than representational.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8827#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list