<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>