anydbm-1.0.1: Interface for DBM-like database systemsContentsIndex
Database.AnyDBM
Portabilityportable
Stabilityprovisional
MaintainerJohn Goerzen <jgoerzen@complete.org>
Contents
The AnyDBM class
AnyDBM utilities
Description

Written by John Goerzen, jgoerzen@complete.org

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.

Synopsis
class AnyDBM a where
closeA :: a -> IO ()
flushA :: a -> IO ()
insertA :: a -> String -> String -> IO ()
deleteA :: a -> String -> IO ()
hasKeyA :: a -> String -> IO Bool
lookupA :: a -> String -> IO (Maybe String)
forceLookupA :: a -> String -> IO String
insertListA :: a -> [(String, String)] -> IO ()
toListA :: a -> IO [(String, String)]
keysA :: a -> IO [String]
valuesA :: a -> IO [String]
mapA :: AnyDBM a => a -> ((String, String) -> IO b) -> IO [b]
strFromA :: AnyDBM a => a -> IO String
strToA :: AnyDBM a => a -> String -> IO ()
The AnyDBM class
class AnyDBM a where

The main class for items implementing this interface.

People implementing this class should provide methods for:

Methods
closeA :: a -> IO ()

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 ()
Flush the object, saving any un-saved data to disk but not closing it. Called automatically by closeA.
insertA
:: aAnyDBM object
-> StringKey
-> StringValue
-> IO ()
Insert the given data into the map. Existing data with the same key will be overwritten.
deleteA :: a -> String -> IO ()
Delete the data referenced by the given key. It is not an error if the key does not exist.
hasKeyA :: a -> String -> IO Bool
True if the given key is present.
lookupA :: a -> String -> IO (Maybe String)
Find the data referenced by the given key.
forceLookupA :: a -> String -> IO String
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 ()
Call insertA on each pair in the given association list, adding them to the map.
toListA :: a -> IO [(String, String)]
Return a representation of the content of the map as a list.
keysA :: a -> IO [String]
Returns a list of keys in the AnyDBM object.
valuesA :: a -> IO [String]
Returns a list of values in the AnyDBM object.
show/hide Instances
AnyDBM utilities
mapA :: AnyDBM a => a -> ((String, String) -> IO b) -> IO [b]
Similar to MapM, but for AnyDBM objects.
strFromA :: AnyDBM a => a -> IO String
Similar to strFromAL -- get a string representation of the entire AnyDBM.
strToA :: AnyDBM a => a -> String -> IO ()
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.
Produced by Haddock version 0.8