
#9163: Ptr should have a phantom role -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | roles/should_compile/Roles2 Blocked By: | Blocking: Related Tickets: #9164 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): goldfire, this gets back to what we discussed in Philly. What we *really* want is for `Ptr` to be defined with a phantom argument, but exported with a representational one. We can work around the trouble today using a newtype: {{{#!hs data Addr = Addr Addr# newtype Ptr a = Ptr_ Addr type role Ptr representational pattern Ptr :: Addr# -> Ptr a pattern Ptr addr# = Ptr_ (Addr addr#) castPtr :: Ptr a -> Ptr b castPtr = coerce ptrCoercion :: Coercion (Ptr a) (Ptr b) ptrCoercion = Coercion }}} The only trouble I see is that the `Generic` representation will change. I kind of doubt anyone's relying on the details of that representation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9163#comment:38 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler