Module FlatCurry.Transform.Exec

Author
Michael Hanus, Steven Libby
Version
September 2025

Implementation of transforming FlatCurry expressions by applying partially and non-deterministically defined expression transformations as long as possible.

Exported Functions


transformFuncsInProg :: (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Prog -> Prog  Deterministic 

Transforms the bodies of all functions in a FlatCurry program according to some expression transformation provided as the first argument. The expression transformation can be partially and also non-deterministically defined. Due to the possibility that the expression transformation might be non-deterministic, it must be passed via run-time choice which is achieved by passing it as a function.

Further infos:
  • might behave indeterministically

transformExpr :: (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> Expr  Deterministic 

Transforms a FlatCurry expression by applying some expression transformation provided as the first argument as long as possible. The expression transformation can be partially and also non-deterministically defined. Due to the possibility that the expression transformation might be non-deterministic, it must be passed via run-time choice which is achieved by passing it as a function.

Although the single transformation steps can be non-deterministic, the strategy to apply such steps is deterministic since it is applied in a bottom-up manner: if there is some node to be transformed, all child nodes are transformed before transformation rules are applied to the node itself.

Further infos:
  • might behave indeterministically

transformExprMax :: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> Expr  Deterministic 

The same as transformExpr but takes the maximum number of transformation steps to be applied as a further argument. If the number is negative, then keep going until no transformation can be applied.

Further infos:
  • might behave indeterministically

transformExprN :: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> (Expr, Int)  Deterministic 

The same as transformExprMax but returns also the number of applied transformation steps.

Further infos:
  • might behave indeterministically

showTransformExpr :: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> (Expr, String, Int)  Deterministic 

The same as transformExprMax but returns also a formatted trace of all applied transformation steps as well as its total number.

Further infos:
  • might behave indeterministically