[GHC] #9163: Ptr should have a phantom role

GHC ghc-devs at haskell.org
Tue Jun 3 13:37:52 UTC 2014


#9163: Ptr should have a phantom role
-------------------------------------+------------------------------------
        Reporter:  simonpj           |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.8.2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by simonpj):

 Richard says: It seemed clear to me that `Ptr` ''should'' be
 representational, thinking that we don't want to coerce a `Ptr Int` to a
 `Ptr Bool`. I don't see any reason why this couldn't be changed.

 Why is `Ptr` a `data` not a `newtype`? If it were a newtype, we could keep
 the role annotation and use `coerce` internally, according to the updated
 Coercible solver.  Answer (from Simon): because the payload is an unboxed
 `Addr#`, so `Ptr` boxes it.  A `newtype` can't have an unboxed payload.

 However, it is crucial that `FunPtr` have a representational argument, as
 normaliseFfiType' depends on this fact. There is a brief comment in
 `TcForeign`, but clearly more comments are necessary. Will do shortly. If
 we want to change `FunPtr`'s role, `normaliseFfiType'` would have to be
 updated, too, but it shouldn't be hard.

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


More information about the ghc-tickets mailing list