Library with operations to encapsulate search, i.e., non-deterministic
computations. Note that some of these operations are not fully declarative,
i.e., the results depend on the order of evaluation and program rules.
There are newer and better approaches the encapsulate search,
in particular, set functions (see module Control.SetFunctions
in package setfunctions
), which should be used.
Author: Michael Hanus
Version: November 2022
getAllValues
:: a -> IO [a]
Gets all values of an expression (similarly to Prolog's findall ).
|
getOneValue
:: a -> IO (Maybe a)
Gets one value of an expression. |
getAllSolutions
:: Data a => (a -> Bool) -> IO [a]
Gets all solutions to a constraint. |
getOneSolution
:: Data a => (a -> Bool) -> IO (Maybe a)
Gets one solution to a constraint. |
getAllFailures
:: a -> (a -> Bool) -> IO [a]
Returns a list of values that do not satisfy a given constraint. |
allValues
:: a -> [a]
Returns all values of an expression. |
someValue
:: a -> a
Returns some value for an expression. |
oneValue
:: a -> Maybe a
Returns just one value for an expression. |
allSolutions
:: Data a => (a -> Bool) -> [a]
Returns all values satisfying a predicate, i.e., all arguments such that the predicate applied to the argument can be evaluated to True .
|
someSolution
:: Data a => (a -> Bool) -> a
Returns some value satisfying a predicate, i.e., some argument such that the predicate applied to the argument can be evaluated to True .
|
oneSolution
:: Data a => (a -> Bool) -> Maybe a
Returns just one value satisfying a predicate. |
isFail
:: a -> Bool
Does the computation of the argument to a head-normal form 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. |
Gets all values of an expression (similarly to Prolog's |
Gets one value of an expression. Returns Nothing if the search space is finitely failed. 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. |
Gets all solutions to a constraint. Conceptually, all solutions are computed on a copy of the constraint, i.e., the evaluation of the constraint does not share any results. Moreover, this evaluation suspends if the constraints contain unbound variables. Similar to Prolog's findall. |
Gets one solution to a constraint. Returns Nothing if the search space is finitely failed. |
Returns a list of values that do not satisfy a given constraint.
|
Returns all values of an expression. Conceptually, all values are 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 values contain 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 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. |
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 all values satisfying a predicate, i.e., all arguments such that
the predicate applied to the argument can be evaluated to Note that this operation is not purely declarative since the ordering of the computed values depends on the ordering of the program rules. |
Returns some value satisfying a predicate, i.e., some argument such that
the predicate applied to the argument can be evaluated to Note that this operation is not purely declarative since the ordering of the computed values depends on the ordering of the program rules. Thus, this operation should be used only if the predicate has a single solution. |
Returns just one value satisfying a predicate.
If there is no such 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. |
Does the computation of the argument to a head-normal form 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 |