In Haskell, is there a way to test whether two IORefs are identical? I'm looking for something like this:
IORef a -> IORef a -> IO Bool
This would be useful if you want to visualize a graph made of IORefs, for example. I don't think it would break referential transparency, because IORefs have a meaningful identity (and the result could be in IO, anyway). And I assume it wouldn't be hard to implement this efficiently, as a pointer comparison.
Is this available somewhere? Or if not, why not?
(Edit: I just found System.Mem.StableName from a different SO question, which looks helpful.)
Don't overthink it. You have instance Eq (IORef a)
, so you can just use ==
, and the result isn't even in IO
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With