The value-supply package [1] provides means to generate unique values
of any kind.  It uses IORefs under the hood, but provides a pure
interface for it (an infinite tree).  Because of this, you need to be
a bit careful how you construct your supply when using multiple
threads.  The same techniques are used in GHC as well (for better or
worse.)

Note that the IDs you get are essentially non-deterministic -- they
rely on evaluation order.

I'm not sure why you need these uniques in the Show instances, though.
 Can't you just store the IDs with your data?

[1]: http://hackage.haskell.org/package/value-supply

On 5 March 2010 12:14, Robert Rothenberg <rob...@gmail.com> wrote:
> I'm implementing a variant of Prolog in Haskell (yes, I know others
> already exist...) and am looking to solve the following issues:
>
> (1) I need to translate anonymous variables "_" into unique variable
> names.  Data.Unique does not give me a printable identifier. Is there
> another package that does this?
>
> (2) Is there a cabal package similar to the Atom.hs module form ginsu,
> that associates strings with unique hashes?
>
> The alternative of course is to maintain state variables and pass them
> along to display and parsing functions, but that makes it difficult to
> make the terms instances of Read/Show without reference to a global
> variable anyhow.
>
> Thanks,
> Rob
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Push the envelope.  Watch it bend.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to