Module FlatCurry.Transform.Utils

Author
Michael Hanus, Steven Libby
Version
August 2025

Utility operations for transformations. TODO: restructure it, e.g., some operations are goodies for FlatCurry.

Exported Datatypes


type Names a = State VarIndex a

This gives a monad for creating unique variable names. It's basically the State monad specilized to State Int a. I need to make my own because State is just a type synonym, and you can't make a monad out of that. ----------------------------------------------------------------------------


newtype ReWriter a

Constructor:

ReWriter :: (VarIndex -> (a, [Step], VarIndex, Bool)) -> ReWriter a

Fields:

Known instances:


Exported Functions


recursiveFunc :: FuncDecl -> Bool  Deterministic 


funcCalls :: FuncDecl -> [(String, String)]  Deterministic 


isFunc :: CombType -> Bool  Deterministic 

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

isCons :: CombType -> Bool  Deterministic 


isPart :: CombType -> Bool  Deterministic 

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

isApp :: CombType -> Bool  Deterministic 


missingVars :: Expr -> Int  Deterministic 


ground :: Expr -> Bool  Deterministic 


recursive :: Int -> Expr -> Bool  Deterministic 

Further infos:
  • partially defined

nonRecursive :: Int -> Expr -> Bool  Deterministic 


replace :: Expr -> [Int] -> Expr -> Expr  Deterministic 

Further infos:
  • partially defined

max1 :: [Int] -> Int  Deterministic 


newVar :: Expr -> Int  Deterministic 


hasVar :: Int -> Expr -> Bool  Deterministic 


uses :: Int -> Expr -> Int  Deterministic 


freeVars :: Expr -> [Int]  Deterministic 


strict :: Int -> Expr -> Bool  Deterministic 

Further infos:
  • partially defined

idSub :: Int -> Expr  Deterministic 

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

(@>) :: Eq a => (a, b) -> (a -> b) -> a -> b  Deterministic 


(-\) :: (Int -> Expr) -> [Int] -> Int -> Expr  Deterministic 


sub :: (Int -> Expr) -> Expr -> Expr  Deterministic 


rename :: Int -> (Int -> Int) -> Expr -> (Expr, Int)  Deterministic 


ren :: (Int -> Int) -> Expr -> StateT Int Identity Expr  Deterministic 


extend :: [Int] -> (Int -> Int) -> StateT Int Identity (Int -> Int)  Deterministic 

Further infos:
  • partially defined

primType :: String -> (String, String)  Deterministic 

Further infos:
  • partially defined

primCon :: String -> (String, String)  Deterministic 

Further infos:
  • partially defined

litCon :: Literal -> (String, String)  Deterministic 

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

litBranchCon :: [BranchExpr] -> (String, String)  Deterministic 

Further infos:
  • partially defined

isLitBranch :: [BranchExpr] -> Bool  Deterministic 

Further infos:
  • partially defined

fork :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)  Deterministic 


mapFst :: (a -> b) -> (a, c) -> (b, c)  Deterministic 


mapSnd :: (a -> b) -> (c, a) -> (c, b)  Deterministic 


mergeMap :: Ord b => (a -> [b]) -> [a] -> [b]  Deterministic 


merge :: Ord a => [[a]] -> [a]  Deterministic 


(++-) :: Ord a => [a] -> [a] -> [a]  Deterministic 

Further infos:
  • defined as right-associative infix operator with precedence 5

(\\-) :: Ord a => [a] -> [a] -> [a]  Deterministic 

Further infos:
  • defined as right-associative infix operator with precedence 5

(&&-) :: Ord a => [a] -> [a] -> [a]  Deterministic 

Further infos:
  • defined as right-associative infix operator with precedence 5

fresh :: StateT Int Identity Int  Deterministic 


curVar :: ReWriter Int  Deterministic 


update :: a -> (String, [Int], Expr) -> Int -> ReWriter a  Deterministic