Module FlatCurry.CaseLifting

This module contains an implementation of a case lifter, i.e., an operation which lifts all nested cases (and also nested lets) in a FlatCurry program into new operations.

NOTE: the new operations contain nonsense types, i.e., this transformation should only be used if the actual function types are irrelevant!

Author: Michael Hanus

Version: February 2020

Summary of exported operations:

defaultLiftOpts :: LiftOptions   
Default options for lifting all nested case/let/free expressions.
defaultNoLiftOpts :: LiftOptions   
Default options for lifting no nested case/let/free expression.
addSuffix2Fun :: LiftOptions -> String -> LiftOptions   
liftProg :: LiftOptions -> Prog -> Prog   
Lift all nested cases in a FlatCurry program.
liftFun :: LiftOptions -> FuncDecl -> [FuncDecl]   
Lift all nested cases in a FlatCurry function.
liftRule :: LiftOptions -> Rule -> (Rule,[FuncDecl])   
liftExp :: LiftOptions -> Bool -> Expr -> (Expr,[FuncDecl])   
liftExpArg :: LiftOptions -> Int -> Expr -> (Expr,[FuncDecl])   
liftBranch :: LiftOptions -> (Int,BranchExpr) -> (BranchExpr,[FuncDecl])   
unboundVars :: Expr -> [Int]   
Find all variables which are not bound in an expression.
unboundVarsInBranch :: BranchExpr -> [Int]   
unionMap :: Eq a => (b -> [a]) -> [b] -> [a]   

Exported datatypes:


LiftOptions

Options for case/let/free lifting.

Constructors:

  • LiftOptions :: Bool -> Bool -> Bool -> Bool -> QName -> LiftOptions

    Fields:

    • liftCase :: Bool
    • liftCArg :: Bool
    • liftLet :: Bool
    • liftFree :: Bool
    • currFun :: QName

Exported operations:

defaultLiftOpts :: LiftOptions   

Default options for lifting all nested case/let/free expressions.

Further infos:
  • solution complete, i.e., able to compute all solutions

defaultNoLiftOpts :: LiftOptions   

Default options for lifting no nested case/let/free expression.

Further infos:
  • solution complete, i.e., able to compute all solutions

addSuffix2Fun :: LiftOptions -> String -> LiftOptions   

Further infos:
  • solution complete, i.e., able to compute all solutions

liftProg :: LiftOptions -> Prog -> Prog   

Lift all nested cases in a FlatCurry program.

liftFun :: LiftOptions -> FuncDecl -> [FuncDecl]   

Lift all nested cases in a FlatCurry function.

liftRule :: LiftOptions -> Rule -> (Rule,[FuncDecl])   

liftExp :: LiftOptions -> Bool -> Expr -> (Expr,[FuncDecl])   

liftExpArg :: LiftOptions -> Int -> Expr -> (Expr,[FuncDecl])   

unboundVars :: Expr -> [Int]   

Find all variables which are not bound in an expression.

unboundVarsInBranch :: BranchExpr -> [Int]   

unionMap :: Eq a => (b -> [a]) -> [b] -> [a]