Simon Peyton-Jones <[EMAIL PROTECTED]> answers my question:
>
> | This is something that I have long been wondering about
> | (perhaps it is just because of my ignorance):
> | Wouldn't stable pointers be a cheaper and more appropriate means
> | to get Ord for MVars, STRefs, and IORefs?
>
> Could be -- but do we really want to clog up the stable-pointer table
> with an entry for every MVar, whether or not anyone is interested in
> ordering?
>
> I think what you want is a distributed way to get a unique,
> as George suggested. Then you can pair that with an MVar when
> you want something comparable. The unique can include the processor
> id, so it can be globally unique. 64 bits?
>
> I'm still leery of putting such a unique inside every MVar, IORef etc.
> But maybe I shouldn't worry.
>
Perhaps I should give some background:
I am interested in implementing graph structures,
and would need to handle mappings between graphs,
or node labellings, or whatever.
All these mappings need not reside in the graph itself,
so they would require some FiniteMap structure.
However, most decent such data types require Ord
for being able to work efficiently.
If IORefs (or whatever I use) are not ordered,
then I have essentially two possibilities:
1) Do the Integer trick: slows down my program
(as actually experienced in OCaml)
2) Do the memory management myself by allocating
huge arrays and using the indices which are in Ord: clumsy and unwieldy
So I would already be happy if IORefs, STRefs and MVars came with a variant
in Ord (consider this as a concrete proposal for the standard library)
--- even if some implementations choose to implement that via the
Integer trick: hopefully the best implementations
would provide something faster ;-)
Best regards,
Wolfram