Utility operations for transformations. TODO: restructure it, e.g., some operations are goodies for FlatCurry.
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:
recursiveFunc
:: FuncDecl -> Bool
funcCalls
:: FuncDecl -> [(String, String)]
missingVars
:: Expr -> Int
recursive
:: Int -> Expr -> Bool
nonRecursive
:: Int -> Expr -> Bool
replace
:: Expr -> [Int] -> Expr -> Expr
(@>)
:: Eq a => (a, b) -> (a -> b) -> a -> b
(-\)
:: (Int -> Expr) -> [Int] -> Int -> Expr
sub
:: (Int -> Expr) -> Expr -> Expr
rename
:: Int -> (Int -> Int) -> Expr -> (Expr, Int)
ren
:: (Int -> Int) -> Expr -> StateT Int Identity Expr
extend
:: [Int] -> (Int -> Int) -> StateT Int Identity (Int -> Int)
primType
:: String -> (String, String)
primCon
:: String -> (String, String)
litCon
:: Literal -> (String, String)
litBranchCon
:: [BranchExpr] -> (String, String)
isLitBranch
:: [BranchExpr] -> Bool
fork
:: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
mapFst
:: (a -> b) -> (a, c) -> (b, c)
mapSnd
:: (a -> b) -> (c, a) -> (c, b)
mergeMap
:: Ord b => (a -> [b]) -> [a] -> [b]
merge
:: Ord a => [[a]] -> [a]
(++-)
:: Ord a => [a] -> [a] -> [a]
(\\-)
:: Ord a => [a] -> [a] -> [a]
(&&-)
:: Ord a => [a] -> [a] -> [a]
fresh
:: StateT Int Identity Int
update
:: a -> (String, [Int], Expr) -> Int -> ReWriter a