<div dir="auto">Sure, but that's okay, because I never need to expose the type to anyone. I'm just nervous because I haven't seen documentation saying those values are type-specific.</div><div class="gmail_extra"><br><div class="gmail_quote">On Feb 11, 2018 10:37 PM, "Edward Kmett" <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Keep in mind a newtype of Foo will have a different TypeRep, but will compare as equal under reallyUnsafePtrEquality#.<div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 11, 2018 at 5:14 AM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="auto">Can I use reallyUnsafePtrEquality# reliably to identify whether a value is a nullary constructor of a particular type? For example, if I have<div dir="auto"><br></div><div dir="auto">data Foo = Foo</div><div dir="auto"><br></div><div dir="auto">Can I write</div><div dir="auto"><br></div><div dir="auto">isFoo :: a -> Bool</div><div dir="auto">isFoo !a = isTrue# (reallyUnsafePtrEquality# a Foo)</div><div dir="auto"><br></div><div dir="auto">instead of</div><div dir="auto"><br></div><div dir="auto">isFoo :: forall a. Typeable a => a -> Bool</div><div dir="auto">isFoo a</div><div dir="auto"> | Just Refl <- eqTypeRep (typeRep @a) (typeRep @Foo)</div><div dir="auto"> , Foo <- a</div><div dir="auto"> = True</div><div dir="auto"> | otherwise = False</div><div dir="auto"><br></div><div dir="auto">The reason I'm asking is because this would let me (potentially) raiseIO# a nullary constructor and then catch# it and see if it was what I was looking for rather than having to open a SomeException to get to an Exception dictionary, open that to get a TypeRep, and then peer inside that to check a Fingerprint. That is, I'd get lighter-weight exceptions that only carry the information I actually need.<br><br></div><div>Thanks,<br></div><div>David<br></div></div>
</div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
</blockquote></div></div>