<div dir="auto">Pattern synonyms can be bundled with type constructors these days.</div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 4, 2018, 7:01 AM Bertram Felgenhauer via Libraries <<a href="mailto:libraries@haskell.org">libraries@haskell.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Carter Schonwald wrote:<br>
> <a href="https://ghc.haskell.org/trac/ghc/ticket/9163" rel="noreferrer noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/9163</a> seems to talk about *why* Ptr<br>
> being phantom actually has a pretty measurable impact on code. (cast ptr<br>
> becomes a noop and this has a measurable impact on a number of application<br>
> measures)<br>
<br>
David's point, I believe, is that the same performance problem could<br>
have been solved by turning Ptr into a newtype, without giving up the<br>
representational that it had before. In fact he brought this up in the<br>
same trac ticket,<br>
<br>
<a href="https://ghc.haskell.org/trac/ghc/ticket/9163#comment:38" rel="noreferrer noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/9163#comment:38</a><br>
<br>
>>>>On Tue, Oct 30, 2018 at 5:57 PM David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank" rel="noreferrer">david.feuer@gmail.com</a>><br>
>>>>wrote:<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>
This will break some imports, since<br>
<br>
import GHC.Ptr (Ptr (..))<br>
<br>
will not import the pattern synonym. This is how Ptr is imported in<br>
both bytestring and vector. But it's not a big deal, I suppose.<br>
<br>
Cheers,<br>
<br>
Bertram<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>