10 Sep
2004
10 Sep
'04
1:34 p.m.
Keith Wansbrough wrote:
... [Bernd discusses his problems using unsafeperformIO to generate unique names, and Keith responds]
Why not just thread (newLabelNr :: Int) through your code to the places that need it? If you do this with other things too, then put them in a record. This is a kind of "poor-man's" state monad.
Alternatively, if you're threading something through your program, why not thread a splittable supply of new names? You can use the supply to generate fresh identifiers directly, and it all behaves purely functionally. There's code for unique supplies here: http://www.csg.csail.mit.edu/~earwig/haskell-lib/index.html Look down the page for "Arbitrary Splittable Supplies". -Jan-Willem Maessen