Le mercredi 29 septembre 2010 18:00:20, Simon Marlow a écrit :
> On 29/09/10 04:54, Mathieu Giorgino wrote:
> > Hi all,
> > 
> > I'm wondering if there is a way to get an hashcode from references
> > (IORef or STRef)? I have looked in the library and a little in the
> > sources of GHC but haven't found anything allowing to do this.
> > 
> > I'm generating Haskell code from the Isabelle/HOL proof assistant, which
> > generate "generic" code for other langages too which all have this
> > notion, and I would so need an equivalent in Haskell.
> > 
> > Have you any hint on how to achieve this, or even if it is possible?
> 
> IORefs themselves have no persistent properties that could be used to
> make a hash value, so you would have to implement this yourself on top
> of IORef, perhaps using Data.Unique for example.  Something like this:
> 
>   data IdIORef a = IdIORef Unique !(IORef a)
> 
>   newIdIORef :: a -> IO (IdIORef a)
>   newIdIORef a = do
>     u <- getUnique
>     r <- newIORef a
>     return (IdIORef u r)
> 
> Cheers,
>       Simon

Great, I will dig into this direction.

Thanks a lot,

Mathieu
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to