Module "Dynamic.curry"

Library for dynamic predicates. This paper contains a description of the basic ideas behind this library.
Currently, it is still experimental so that its interface might be slightly changed in the future.
A dynamic predicate p with arguments of type t1,...,tn must be declared by:
p :: t1 -> ... -> tn -> Dynamic
p = dynamic

A dynamic predicate where all facts should be persistently stored in the directory DIR must be declared by:
p :: t1 -> ... -> tn -> Dynamic
p = persistent "file:DIR"

Author: Michael Hanus

Version: December 2005


 Exported names:

Datatypes:
Dynamic

Functions:
<> | abortTransaction | assert | dynamic | getDynamicSolution | getDynamicSolutions | getKnowledge | isKnown | persistent | retract | transaction | |&> | |>


 Summary of exported functions:

dynamic  :: a  deterministic 
          dynamic is only used for the declaration of a dynamic predicate and should not be used elsewhere.
persistent  :: String -> a  deterministic 
          persistent is only used for the declaration of a persistent dynamic predicate and should not be used elsewhere.
(<>)  :: Dynamic -> Dynamic -> Dynamic  deterministic 
          Combine two dynamics.
(|>)  :: Dynamic -> Bool -> Dynamic  deterministic 
          Restrict a dynamic with a condition.
(|&>)  :: Dynamic -> Success -> Dynamic  deterministic 
          Restrict a dynamic with a constraint.
assert  :: Dynamic -> IO ()  deterministic flexible+rigid
          Asserts new facts (without free variables!) about dynamic predicates.
retract  :: Dynamic -> IO Bool  deterministic flexible+rigid
          Deletes facts (without free variables!) about dynamic predicates.
getKnowledge  :: IO (Dynamic -> Success)  deterministic 
          Returns the knowledge at a particular point of time about dynamic predicates.
getDynamicSolutions  :: (a -> Dynamic) -> IO [a]  deterministic 
          Returns all answers to an abstraction on a dynamic expression.
getDynamicSolution  :: (a -> Dynamic) -> IO (Maybe a)  deterministic 
          Returns an answer to an abstraction on a dynamic expression.
isKnown  :: Dynamic -> IO Bool  deterministic flexible
          Returns True if there exists the argument facts (without free variables!) and False, otherwise.
transaction  :: IO a -> IO (Maybe a)  deterministic 
          Perform an action (usually containing updates of various dynamic predicates) as a single transaction.
abortTransaction  :: IO a  deterministic 
          Aborts the current transaction.

 Imported modules:

AllSolutions
Prelude

 Exported datatypes:

Dynamic

The general type of dynamic predicates.

Constructors:



 Exported functions:

dynamic :: a  deterministic 

dynamic is only used for the declaration of a dynamic predicate and should not be used elsewhere.


persistent :: String -> a  deterministic 

persistent is only used for the declaration of a persistent dynamic predicate and should not be used elsewhere.


(<>) :: Dynamic -> Dynamic -> Dynamic  deterministic 

Combine two dynamics.

Further infos:
  • defined as right-associative infix operator with precedence 2
  • solution complete, i.e., able to compute all solutions

(|>) :: Dynamic -> Bool -> Dynamic  deterministic 

Restrict a dynamic with a condition.

Further infos:
  • defined as left-associative infix operator with precedence 1
  • solution complete, i.e., able to compute all solutions

(|&>) :: Dynamic -> Success -> Dynamic  deterministic 

Restrict a dynamic with a constraint.

Further infos:
  • defined as left-associative infix operator with precedence 1

assert :: Dynamic -> IO ()  deterministic flexible+rigid

Asserts new facts (without free variables!) about dynamic predicates. Conditional dynamics are asserted only if the condition holds.


retract :: Dynamic -> IO Bool  deterministic flexible+rigid

Deletes facts (without free variables!) about dynamic predicates. Conditional dynamics are retracted only if the condition holds. Returns True if all facts to be retracted exist, otherwise False is returned.


getKnowledge :: IO (Dynamic -> Success)  deterministic 

Returns the knowledge at a particular point of time about dynamic predicates. If other processes made changes to persistent predicates, these changes are read and made visible to the currently running program.


getDynamicSolutions :: (a -> Dynamic) -> IO [a]  deterministic 

Returns all answers to an abstraction on a dynamic expression. If other processes made changes to persistent predicates, these changes are read and made visible to the currently running program.


getDynamicSolution :: (a -> Dynamic) -> IO (Maybe a)  deterministic 

Returns an answer to an abstraction on a dynamic expression. Returns Nothing if no answer exists. If other processes made changes to persistent predicates, these changes are read and made visible to the currently running program.


isKnown :: Dynamic -> IO Bool  deterministic flexible

Returns True if there exists the argument facts (without free variables!) and False, otherwise.


transaction :: IO a -> IO (Maybe a)  deterministic 

Perform an action (usually containing updates of various dynamic predicates) as a single transaction. This is the preferred way to execute any changes to persistent dynamic predicates if there might be more than one process that may modify the definition of such predicates in parallel.
Before the transaction is executed, the access to all persistent predicates is locked (i.e., no other process can perform a transaction in parallel). After the successful transaction, the access is unlocked so that the updates performed in this transaction become persistent and visible to other processes. Otherwise (i.e., in case of a failure or abort of the transaction), the changes of the transaction to persistent predicates are ignored and Nothing is returned.
In general, a transaction should terminate and all failures inside a transaction should be handled (execept for abortTransaction). If a transaction is externally interrupted (e.g., by killing the process), some locks might never be removed. However, they can be explicitly removed by deleting the corresponding lock files reported at startup time.
Nested transactions are not supported and lead to a failure.


abortTransaction :: IO a  deterministic 

Aborts the current transaction. If a transaction is aborted, the remaining actions of the transaction are not executed and all changes to persistent dynamic predicates made in this transaction are ignored.
abortTransaction should only be used in a transaction. Although the execution of abortTransaction always fails (basically, it writes an abort record in log files, unlock them and then fails), the failure is handled inside transaction.

Further infos:
  • externally defined


Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Aug 28 15:27:34 2008