Robert Rothenberg <[email protected]> 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.
Well, you can use hashUnique, but there are no guarantees about collisions. If you need thread safety, the easiest approach is an id generator thread like this: idVar <- newEmptyMVar forkIO . mapM (putMVar idVar) $ [0..] let getId = takeMVar idVar If you don't need it, you will need to pass state around, just like with Data.Unique. Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
