-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Atom (or symbol) datatype for fast comparision and sorting. -- -- This module provides an abstract datatype for atoms, such that: -- -- -- -- This module is thread-safe. @package simple-atom @version 0.2 -- | Symbols without a central symbol table. -- -- Symbols provide the following efficient operations: -- -- -- -- Many implementations often have the additional property that each -- symbol descriptor only exists once in memory. This implementation -- slightly relaxes this property: -- -- -- -- This allows the following additional properties not present in -- conventional implementations: -- -- -- -- Inspired by Richard OKeefes message to Erlang's eeps mailing -- list http://www.erlang.org/cgi-bin/ezmlm-cgi/5/057, which in -- turn was inspired by the Logix implementation of Flat Concurrent -- Prolog. module Data.Atom.UF -- | A symbol. -- -- Note that the ordering on a is not preserved on -- Symbol a. Symbols are ordered by their hashes, and only if -- the hashes are equal will the ordering on a be used. We have: -- --
--     x == y ==> intern x == intern y
--   
--   let sx = intern x
--         sy = intern y
--     in
--       (sx < sy) == ((symbolHash sy < symbolHash sx) ||
--                     symbolHash sy == symbolHash sx && x < y)
--   
data Symbol a -- | Create a new local symbol. For best performance use internInto -- together with a symbol table / map. intern :: (a -> Word64) -> a -> Symbol a -- | Insert a symbol into an existing table. internInto :: SymTab s => (a -> Word64) -> s a -> a -> (s a, Symbol a) class SymTab s lookupSymbol :: SymTab s => s a -> a -> Maybe (Symbol a) insertSymbol :: SymTab s => a -> (Symbol a) -> s a -> s a -- | Returns the hash of the symbol. symbolHash :: Symbol a -> Word64 instance Show a => Show (Symbol a) instance Ord a => Ord (Symbol a) instance Ord a => Eq (Symbol a) module Data.Atom.Simple -- | A Symbol. This is essentially a String, but with -- different performance characteristics: -- -- -- -- It is currently implemented as follows. -- -- data Symbol -- | Turn a String into a Symbol. -- -- Note, however, that this function contains a space leak. It has -- internal state (the symbol table) but is referentially transparent. -- Unfortunately, there is no way to delete items from the symbol table. -- -- (This function is, of course, thread-safe.) intern :: String -> Symbol instance Ord Symbol instance Eq Symbol instance Show Symbol