Implementation of transforming FlatCurry expressions by applying partially and non-deterministically defined expression transformations as long as possible.
transformFuncsInProg
:: (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Prog -> Prog
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.
transformExpr
:: (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> Expr
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.
transformExprMax
:: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> Expr
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.
transformExprN
:: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> (Expr, Int)
The same as transformExprMax but returns also the number of applied transformation steps.
showTransformExpr
:: Int -> (() -> (Int, [Int]) -> Expr -> (Expr, String, Int)) -> Expr -> (Expr, String, Int)
The same as transformExprMax but returns also a formatted trace of all applied transformation steps as well as its total number.