[Haskell] "global variables" and code optimization
Jan-Willem Maessen - Sun Labs East
Janwillem.Maessen at Sun.COM
Fri Sep 10 09:34:42 EDT 2004
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:
Look down the page for "Arbitrary Splittable Supplies".
More information about the Haskell