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

GHC ghc-devs at haskell.org
Mon Jul 9 13:26:17 UTC 2018


#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 RyanGlScott):

 I think there's a bit of a tension here between two different camps who
 want `Ptr`'s role signature to be phantom or representational for
 different purposes:

 1. Some have argued that it should be phantom because that allows one to
 implement `castPtr` (a quite fundamental operation) efficiently via
 `coerce`.
 2. Others have argued that it should be representational to avoid coercing
 between `Ptr`s whose underlying types have different representations.

 Personally, I find myself more aligned towards the (1) camp, for the
 simple reason that `Ptr`s are not intended to be a safe abstraction. There
 are many ways you can cause a Haskell program to segfault through reckless
 use of `Ptr`s (even without `castPtr`), so changing its role signature
 isn't going to change things in this regard.

 In light of this, I'm inclined to believe that the proper fix to dominic's
 problem is to give `Vector` a role signature of representational, as
 `Vector` is what is intended to be a safe abstraction.

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


More information about the ghc-tickets mailing list