Ptr type

Simon Peyton Jones simonpj at
Tue Jun 3 11:13:19 UTC 2014

In GHC.Ptr we see

type role Ptr representational

data Ptr a = Ptr Addr# deriving (Eq, Ord)
with no comments.  Why is Ptr representational?
In the same module we have castPtr, which unpacks and repacks a Ptr.  If Ptr was phantom, we could use coerce.  And that in turn would actually make a lot of code more efficient - there are lots of calls to castPtr.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list