anydbm-1.0.5: Interface for DBM-like database systems

MaintainerJohn Goerzen <>




Written by John Goerzen,

This module provides a generic infrastructure for supporting storage of hash-like items with String -> String mappings. It can be used for in-memory or on-disk items.


The AnyDBM class

class AnyDBM a whereSource

The main class for items implementing this interface.

People implementing this class should provide methods for:


closeA :: a -> IO ()Source

Close the object, writing out any unsaved data to disk if necessary.

If you implement this, make sure your implementation calls flushA.

Note: if you have an object opened for writing, you MUST call closeA on it when you are done. Implementations are not required to preserve your data otherwise.

flushA :: a -> IO ()Source

Flush the object, saving any un-saved data to disk but not closing it. Called automatically by closeA.



:: a

AnyDBM object

-> String


-> String


-> IO () 

Insert the given data into the map. Existing data with the same key will be overwritten.

deleteA :: a -> String -> IO ()Source

Delete the data referenced by the given key. It is not an error if the key does not exist.

hasKeyA :: a -> String -> IO BoolSource

True if the given key is present.

lookupA :: a -> String -> IO (Maybe String)Source

Find the data referenced by the given key.

forceLookupA :: a -> String -> IO StringSource

Look up the data and raise an exception if the key does not exist. The exception raised is PatternMatchFail, and the string accompanying it is the key that was looked up.

insertListA :: a -> [(String, String)] -> IO ()Source

Call insertA on each pair in the given association list, adding them to the map.

toListA :: a -> IO [(String, String)]Source

Return a representation of the content of the map as a list.

keysA :: a -> IO [String]Source

Returns a list of keys in the AnyDBM object.

valuesA :: a -> IO [String]Source

Returns a list of values in the AnyDBM object.

AnyDBM utilities

mapA :: AnyDBM a => a -> ((String, String) -> IO b) -> IO [b]Source

Similar to MapM, but for AnyDBM objects.

strFromA :: AnyDBM a => a -> IO StringSource

Similar to strFromAL -- get a string representation of the entire AnyDBM.

strToA :: AnyDBM a => a -> String -> IO ()Source

Similar to strToAL -- load a string representation into the AnyDBM. You must supply an existing AnyDBM object; the items loaded from the string will be added to it.