<div dir="ltr"><div dir="ltr"><a href="https://ghc.haskell.org/trac/ghc/ticket/9163">https://ghc.haskell.org/trac/ghc/ticket/9163</a> seems to talk about *why* Ptr being phantom actually has a pretty measurable impact on code. (cast ptr becomes a noop and this has a measurable impact on a number of application measures)<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 2, 2018 at 7:27 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">woops:<div><br></div><div>i mis stated my previous email, misread some stuff, please ignore it :) </div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 2, 2018 at 7:25 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">my understanding is ANY non phantom role suffices in this case .. <div><br></div><div>i dont use the coercible class in this context, my main concern is how role selection will impact client type classes / GND / etc</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 2, 2018 at 6:34 AM Matthew Pickering <<a href="mailto:matthewtpickering@gmail.com" target="_blank">matthewtpickering@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Making `Ptr` (and ForeignPtr) have a nominal role would have prevented<br>
recent bugs where it was possible to coerce Vectors between any types.<br>
<br>
See: <a href="https://github.com/haskell/vector/pull/224" rel="noreferrer" target="_blank">https://github.com/haskell/vector/pull/224</a><br>
and: <a href="https://phabricator.haskell.org/D4941" rel="noreferrer" target="_blank">https://phabricator.haskell.org/D4941</a><br>
On Tue, Oct 30, 2018 at 5:57 PM David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br>
><br>
> Currently, we have<br>
><br>
> data Ptr a = Ptr Addr#<br>
> type role Ptr phantom<br>
><br>
> This is weird: accidentally coercing a pointer to a different type is very bad. The only reason Ptr has this role is that without it, castPtr and such may not be free or will involve unsafe coercions.<br>
><br>
> Thankfully, we have enough power to fix this now.<br>
><br>
> data Addr = Ptr_ Addr#<br>
><br>
> newtype Ptr a = Ptr_ Addr<br>
> type role Ptr nominal<br>
><br>
> pattern Ptr :: Addr# -> Ptr a<br>
> pattern Ptr a# = Ptr_ (Addr a#)<br>
><br>
> castPtr :: Ptr a -> Ptr b<br>
> castPtr (Ptr a) = Ptr a<br>
><br>
> ptrCoercible<br>
> :: ((forall a b. Coercible (Ptr a) (Ptr b)) => r)<br>
> -> r<br>
> ptrCoercible r = r<br>
><br>
> ptrCoercion :: Coercion (Ptr a) (Ptr b)<br>
> ptrCoercion = Coercion<br>
><br>
> I propose that we do this.<br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>