Package transf :: Package lib :: Module combine
[frames] | no frames]

Module combine



Transformation combinators.

Functions
 
Not(operand)
Fail if a transformation applies.
 
Try(operand)
Attempt a transformation, otherwise return the term unmodified.
 
Where(operand)
Succeeds if the transformation succeeds, but returns the original term.
 
Composition(loperand, roperand)
Transformation composition.
 
Choice(loperand, roperand)
Attempt the first transformation, transforming the second on failure.
 
GuardedChoice(operand1, operand2, operand3)
If operand1 succeeds then operand2 is applied, otherwise operand3 is applied.
 
UndeterministicChoice(operands)
Chooses one of the operand transformations such that the one it chooses succeeds.
 
If(loperand, roperand)
If the first transformation succeeds, then applies the second transformation.
 
IfElse(operand1, operand2, operand3)
If the first transformation succeeds, then apply the second transformation.
 
IfElifElse(clauses, otherwise=None)
Nested if-then-else combinator.
 
Switch(expr, cases, otherwise=None)
Switch combination.
Function Details

GuardedChoice(operand1, operand2, operand3)

 
If operand1 succeeds then operand2 is applied, otherwise operand3 is applied. If operand2 fails, the complete expression fails; no backtracking to operand3 takes place.

UndeterministicChoice(operands)

 
Chooses one of the operand transformations such that the one it chooses succeeds. If all operand transformations fail, then the choice fails as well. Operationally, the operand transformations are tried, by an unspecified order.

If(loperand, roperand)

 
If the first transformation succeeds, then applies the second transformation. Otherwise, return the input term unmodified.

IfElse(operand1, operand2, operand3)

 
If the first transformation succeeds, then apply the second transformation. Otherwise, applies the third transformation.

IfElifElse(clauses, otherwise=None)

 
Nested if-then-else combinator.
Parameters:
  • clauses - sequence of (premise, consequence) transformation tuples to be tried in order.
  • otherwise - optional transformation to be applied if all the above premises fail.

Switch(expr, cases, otherwise=None)

 
Switch combination.
Parameters:
  • cases - sequence of (match term, consequence transformation) tuples; order is irrelevant.
  • otherwise - optional transformation to be applied if the term does not match any of the input cases.