Module Control.Search.AllValues

Exported Functions


getAllValues :: a -> IO [a]  Deterministic 

Gets all values of an expression (similarly to Prolog's findall). Conceptually, the value is computed on a copy of the expression, i.e., the evaluation of the expression does not share any results.

The strategy to search for all values depends on the Curry system:

  • PAKCS uses a depth-first search strategy and computes all values at once,
  • KiCS2 uses a breadth-first search strategy and computes all values lazily.
  • KMCC uses a fair search strategy and computes all values lazily.
  • Curry2Go uses a fair search strategy and computes all values lazily.
    In PAKCS, the evaluation suspends as long as the expression or its computed value contain unbound variables.

Further infos:
  • might behave indeterministically

getAllValuesDFS :: a -> IO [a]  Deterministic 

Gets all values of an expression. This operation is similar to getAllValues but uses a depth-first search strategy (if available). Thus, it could be more efficient than getAllValues but it might not terminate (instead of computing of all values) if the search space is infinite.

Further infos:
  • might behave indeterministically

getOneValue :: a -> IO (Maybe a)  Deterministic 

Gets one value of an expression or Nothing if the expression has no value. Conceptually, the value is computed on a copy of the expression, i.e., the evaluation of the expression does not share any results.

The strategy to search for a value depends on the Curry system:

  • PAKCS uses a depth-first search strategy,
  • KiCS2 uses a breadth-first search strategy, and
  • KMCC uses a fair search strategy.
  • Curry2Go uses a fair search strategy.

In PAKCS, the evaluation suspends as long as the expression or its computed value contain unbound variables.

Further infos:
  • might behave indeterministically

getOneValueDFS :: a -> IO (Maybe a)  Deterministic 

Gets one value of an expression or Nothing if the expression has no value. This operation is similar to getOneValue but uses a depth-first search strategy (if available). Thus, it could be more efficient than getOneValue but it might not terminate (instead of computing of value) if the search space is infinite.

Further infos:
  • might behave indeterministically

getAllFailures :: a -> (a -> Bool) -> IO [a]  Deterministic 

Returns a list of values that do not satisfy a given constraint. As a simple example, the expression

getAllFailures ([] ? [1] ? [2]) (\xs -> head xs =:= 1)

evaluates to [[], [2]].

:: a  an expression ´e´ (e.g., a generator evaluable to various values)
-> a -> Bool  a constraint ´c´ that should not be satisfied
-> IO [a]  list of all values of e such that (c e) is not provable
Further infos:
  • might behave indeterministically