uniqueid-0.1: Splittable Unique Identifier Supply



This module provides splittable supplies for unique identifiers. The main idea gows back to L. Augustsson, M. Rittri, and D. Synek and is described in their paper 'On generating unique names' (Journal of Functional Programming 4(1), 1994. pp. 117-123). The implementation at hand is taken from the GHC sources and includes bit fiddling to allow multiple supplies that generate unique identifiers by prepending a character given at initialization.



data Id Source

Unique identifiers are of type Id and can be hashed to an Int usning the function hashedId.


data IdSupply Source

Supplies for unique identifiers are of type IdSupply and can be split into two new supplies or yield a unique identifier.

initIdSupply :: Char -> IO IdSupplySource

Generates a new supply of unique identifiers. The given character is prepended to generated numbers.

splitIdSupply :: IdSupply -> (IdSupply, IdSupply)Source

Splits a supply of unique identifiers to yield two of them.

idFromSupply :: IdSupply -> IdSource

Yields the unique identifier from a supply.