Module "KeyDatabase.curry"

This module provides a general interface for databases (persistent predicates) where each entry consists of a key and an info part. The key is an integer and the info is arbitrary. All functions are parameterized with a dynamic predicate that takes an integer key as a first parameter.

Author: Bernd Brassel, Michael Hanus

Version: March 2007


 Exported names:

Functions:
allDBInfos | allDBKeyInfos | allDBKeys | cleanDB | deleteDBEntry | existsDBKey | getDBInfo | getDBInfos | groupByIndex | index | newDBEntry | sortByIndex | updateDBEntry


 Summary of exported functions:

existsDBKey  :: (Int -> a -> Dynamic) -> Int -> Query Bool  deterministic 
          Exists an entry with a given key in the database?
allDBKeys  :: (Int -> a -> Dynamic) -> Query [Int]  deterministic 
          Query that returns all keys of entries in the database.
allDBInfos  :: (Int -> a -> Dynamic) -> Query [a]  deterministic 
          Query that returns all infos of entries in the database.
allDBKeyInfos  :: (Int -> a -> Dynamic) -> Query [(Int,a)]  deterministic 
          Query that returns all key/info pairs of the database.
getDBInfo  :: (Int -> a -> Dynamic) -> Int -> Query a  deterministic 
          Gets the information about an entry in the database.
index  :: a -> [a] -> Int  deterministic 
          compute the position of an entry in a list fail, if given entry is not an element.
sortByIndex  :: [(Int,a)] -> [a]  deterministic 
          Sorts a given list by associated index .
groupByIndex  :: [(Int,a)] -> [[a]]  deterministic 
          Sorts a given list by associated index and group for identical index.
getDBInfos  :: (Int -> a -> Dynamic) -> [Int] -> Query [a]  deterministic 
          Gets the information about a list of entries in the database.
deleteDBEntry  :: (Int -> a -> Dynamic) -> Int -> Transaction ()  deterministic 
          Deletes an entry with a given key in the database.
updateDBEntry  :: (Int -> a -> Dynamic) -> Int -> a -> Transaction ()  deterministic 
          Overwrites an existing entry in the database.
newDBEntry  :: (Int -> a -> Dynamic) -> a -> Transaction Int  deterministic 
          Stores a new entry in the database and return the key of the new entry.
cleanDB  :: (Int -> a -> Dynamic) -> Transaction ()  deterministic 
          Deletes all entries in the database.

 Imported modules:

Database
Dynamic
Integer
List
Prelude
Sort

 Exported datatypes:


 Exported functions:

existsDBKey :: (Int -> a -> Dynamic) -> Int -> Query Bool  deterministic 

Exists an entry with a given key in the database?

Example call:  (existsDBKey db key)

Parameters:
db - the database (a dynamic predicate)
key - a key (an integer)

allDBKeys :: (Int -> a -> Dynamic) -> Query [Int]  deterministic 

Query that returns all keys of entries in the database.


allDBInfos :: (Int -> a -> Dynamic) -> Query [a]  deterministic 

Query that returns all infos of entries in the database.


allDBKeyInfos :: (Int -> a -> Dynamic) -> Query [(Int,a)]  deterministic 

Query that returns all key/info pairs of the database.


getDBInfo :: (Int -> a -> Dynamic) -> Int -> Query a  deterministic 

Gets the information about an entry in the database.

Example call:  (getDBInfo db key)

Parameters:
db - the database (a dynamic predicate)
key - the key of the entry (an integer)

index :: a -> [a] -> Int  deterministic 

compute the position of an entry in a list fail, if given entry is not an element.

Example call:  (index x xs)

Parameters:
x - the entry searched for
xs - the list to search in

sortByIndex :: [(Int,a)] -> [a]  deterministic 

Sorts a given list by associated index .


groupByIndex :: [(Int,a)] -> [[a]]  deterministic 

Sorts a given list by associated index and group for identical index. Empty lists are added for missing indexes


getDBInfos :: (Int -> a -> Dynamic) -> [Int] -> Query [a]  deterministic 

Gets the information about a list of entries in the database.

Example call:  (getDBInfos db keys)

Parameters:
db - the database (a dynamic predicate)
keys - the list of keys of the entry (integers)

deleteDBEntry :: (Int -> a -> Dynamic) -> Int -> Transaction ()  deterministic 

Deletes an entry with a given key in the database.

Example call:  (deleteDBEntry db key)

Parameters:
db - the database (a dynamic predicate)
key - the key of the entry (an integer)

updateDBEntry :: (Int -> a -> Dynamic) -> Int -> a -> Transaction ()  deterministic 

Overwrites an existing entry in the database.

Example call:  (updateDBEntry db key info)

Parameters:
db - the database (a dynamic predicate)
key - the key of the entry (an integer)
info - the information to be stored in the updated entry

newDBEntry :: (Int -> a -> Dynamic) -> a -> Transaction Int  deterministic 

Stores a new entry in the database and return the key of the new entry.

Example call:  (newDBEntry db info)

Parameters:
db - the database (a dynamic predicate)
info - the information to be stored in the new entry

cleanDB :: (Int -> a -> Dynamic) -> Transaction ()  deterministic 

Deletes all entries in the database.



Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Jun 16 17:14:18 2009