Module FlatCurry.CaseLifting

Author
Michael Hanus
Version
November 2020

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!

Exported Datatypes


data LiftOptions

Options for case/let/free lifting.

Constructors:

  • LiftOptions :: Bool -> Bool -> LiftOptions

    Fields:


data LiftState

Options for case/let/free lifting.

Constructors:


type LiftingState a = State LiftState a

Exported Functions


defaultLiftOpts :: LiftOptions  Deterministic 

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

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

defaultNoLiftOpts :: LiftOptions  Deterministic 

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

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

getOpts :: StateT LiftState Identity LiftOptions  Deterministic 


genFuncName :: String -> StateT LiftState Identity (String, String)  Deterministic 


addFun2State :: FuncDecl -> LiftState -> LiftState  Deterministic 

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

liftProg :: LiftOptions -> Prog -> Prog  Deterministic 

Lift nested cases/lets/free in a FlatCurry program (w.r.t. options).


liftTopFun :: FuncDecl -> StateT LiftState Identity [FuncDecl]  Deterministic 


liftNewFun :: FuncDecl -> StateT LiftState Identity FuncDecl  Deterministic 


liftRule :: Rule -> StateT LiftState Identity Rule  Deterministic 


liftExp :: Bool -> Expr -> StateT LiftState Identity Expr  Deterministic 

Further infos:
  • partially defined

unboundVars :: Expr -> [Int]  Deterministic 

Find all variables which are not bound in an expression.


unboundVarsInBranch :: BranchExpr -> [Int]  Deterministic 


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