[GHC] #8827: Inferring Safe mode with GeneralizedNewtypeDeriving is wrong
GHC
ghc-devs at haskell.org
Sat Mar 22 17:15:14 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 nomeata):
> I'll admit to liking the general flavor of comment:27, but the details
elude me somewhat. What, precisely, would go after the word deriving?
Well, either `data MyList a = [a] deriving Coercible`, which will give you
the same instance as described in the paper, but independent of the scope
of the constructor.
Or `deriving instance Coercible a b => Coercible (Map k a) (Map k b)`,
which allows you to control the coercing
This is even strictly more powerful that our current system: It would
allow the author of `Map` to export the instance above, while still using
`coerce` in his code (with constructors in scope and no abstraction to
follow) to coerce the key, if he wishes to do so.
> What's the interaction between derived instances and role annotations?
Could a derived instance be more restrictive than the assigned roles? (It
certainly couldn't be less restrictive!) How would a user specify that?
As you say: The derived instance have to adhere the roles, but may be more
restrictive (if created using a standalone deriving instance). The non-
standalone-deriving instance would be the one that we have currently.
OTOH, this gets hairy once we mix tycons with exported constructors and
tycons without, but with exported Coercible instances, in a new data
declaration and try to find out when we can coerce under ''that''... and
that issue is well handled by roles and role inference. *shrug*
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8827#comment:30>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list