Library with operations to encapsulate search, i.e., non-deterministic computations. Note that these operations are not fully declarative, i.e., the results depend on the order of evaluation and program rules. This is due to the fact that the search operators work on a copy of the current expression to be encapsulated. The potential problems of this method are discussed in this paper:
B. Brassel, M. Hanus, F. Huch: Encapsulating Non-Determinism in Functional Logic Computations Journal of Functional and Logic Programming, No. 6, EAPLS, 2004
There are newer and better approaches the encapsulate search,
in particular, set functions (see module Control.Search.SetFunctions
which should be used.
Author: Michael Hanus
Version: October 2023
allValues
:: a -> [a]
Returns all values of an expression. |
oneValue
:: a -> Maybe a
Returns just one value for an expression. |
someValue
:: a -> a
Returns some value for an expression. |
isFail
:: a -> Bool
Does the computation of the argument to a value fail? Conceptually, the argument is evaluated on a copy, i.e., even if the computation does not fail, it has not been evaluated. |
rewriteAll
:: a -> [a]
Gets all values computable by term rewriting. |
rewriteSome
:: a -> Maybe a
Similarly to rewriteAll but returns only some value computable by term rewriting. |
Returns all values of an expression. Conceptually, the value is computed on a copy of the expression, i.e., the evaluation of the expression does not share any results. In PAKCS, the evaluation suspends as long as the expression contains unbound variables or the computed value contains unbound variables. Note that this operation is not purely declarative since the ordering of the computed values depends on the ordering of the program rules.
|
Returns just one value for an expression.
If the expression has no value, Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules. Thus, this operation should be used only if the expression has a single value.
|
Returns some value for an expression. If the expression has no value, the computation fails. Conceptually, the value is computed on a copy of the expression, i.e., the evaluation of the expression does not share any results. In PAKCS, the evaluation suspends as long as the expression contains unbound variables or the computed value contains unbound variables. Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules. Thus, this operation should be used only if the expression has a single value. |
Does the computation of the argument to a value fail? Conceptually, the argument is evaluated on a copy, i.e., even if the computation does not fail, it has not been evaluated. |
Gets all values computable by term rewriting.
In contrast to
|
Similarly to rewriteAll
but returns only some value computable
by term rewriting. Returns
|