Stability | experimental |
---|---|
Maintainer | developer@flocc.net |
Safe Haskell | None |
For more information please see http://www.flocc.net/
- data Expr
- data IdxTree
- data Val
- data NeverEq = NeverEq
- getExprId :: Expr -> Idx
- getIdxTreeIds :: IdxTree -> [Idx]
- getIdxTreeId :: IdxTree -> Idx
- makeExprMap :: Expr -> [(Idx, Expr)]
- showExprTreeWithIds :: Expr -> String
- showExprTree :: a -> (a -> Idx -> String) -> Int -> Expr -> String
- makeDemoGraph :: State IdxSet Expr
- renewExprIds :: Monad a => Expr -> StateT IdxSet a Expr
- newExpr :: Monad m => (Idx -> a) -> StateT IdxSet m a
- newExprId :: Monad m => StateT IdxSet m Idx
- newExprVarId :: Monad m => StateT IdxSet m Idx
- renewIdAndExprIds :: Monad a => IdxTree -> Expr -> StateT IdxSet a (IdxTree, Expr)
- initExprVarIds :: Monad m => [(String, Idx)] -> Expr -> StateT IdxSet m Expr
- initIdxTreeExpIds :: Monad m => IdxTree -> StateT IdxSet m IdxTree
- initIdxTreeVarIds :: Monad m => IdxTree -> StateT IdxSet m (IdxTree, [(String, Idx)])
- replaceIdxTreeIds :: Monad m => IdxTree -> StateT [(Idx, Idx)] (StateT IdxSet m) IdxTree
- replaceExprIds :: Monad m => Expr -> StateT [(Idx, Idx)] (StateT IdxSet m) Expr
- visitExprTree :: Monad m => (a -> Expr -> m Expr) -> (a -> IdxTree -> m (IdxTree, a)) -> a -> Expr -> m Expr
- replaceExprIdsOnly :: Monad m => (Expr -> Bool) -> Expr -> StateT (Map Idx Idx) (StateT IdxSet m) Expr
- class StructEq a where
- getLetVarExprIds :: Expr -> [(String, Idx)]
- countExprs :: (Expr -> Bool) -> Expr -> Int
- isAppExpr :: Expr -> Bool
- isLeafExpr :: Expr -> Bool
- getIdxTreeVars :: IdxTree -> [(String, Idx)]
- isVarExpr :: Expr -> Bool
- getVarExprName :: Expr -> String
- getExprById :: Idx -> Expr -> Maybe Expr
- checkExpIdsUnique :: Monad m => String -> Expr -> m Expr
- checkExpIdsUnique2 :: Monad m => String -> Expr -> IdxMonad m Expr
- maxExpId :: Monad m => Expr -> m Idx
- removeEmptyTups :: Expr -> Expr
- getFreeExprVars :: Expr -> [(String, Idx)]
- getVarExprIds :: Expr -> [(Idx, Idx)]
- foldExpr :: (Expr -> a) -> (IdxTree -> a) -> (a -> a -> a) -> Expr -> a
- filterExprs :: (Expr -> Bool) -> Expr -> [Expr]
- removeFunApps :: (Expr -> Bool) -> Expr -> Expr
Documentation
data Expr
Expression tree grammar
data IdxTree
Identifier patterns
data Val
Value carriers
data NeverEq
A value where comparisons with itself are never equal
getIdxTreeIds :: IdxTree -> [Idx]
Returns a list of all the var ids in the idx tree
getIdxTreeId :: IdxTree -> Idx
makeExprMap :: Expr -> [(Idx, Expr)]
Makes a lookup table mapping expr ids to expressions
showExprTreeWithIds :: Expr -> String
showExprTreeWithIds shows an expression with dangling expression ids for each term.
showExprTree :: a -> (a -> Idx -> String) -> Int -> Expr -> String
Shows expression tree with dangling data |Takes a context object, some function that takes a context and |an expr id and returns a string, an integer number of spaces to indent |and an expression and returns a string rendering of the expression with |relevent data from the context attached.
makeDemoGraph :: State IdxSet Expr
Initial index we think is safe to use for demo graph generation initidx = length globalTypes |Initial indices we think are safe to use for demo graph generation initidxs = [initidx, initidx, initidx]
Creates a new demo graph, in this case a matrix multiply
renewExprIds :: Monad a => Expr -> StateT IdxSet a Expr
Renew all expression ids in the expression
newExpr :: Monad m => (Idx -> a) -> StateT IdxSet m a
Creates a new expr with a new expression id using the data constructor passed
newExprVarId :: Monad m => StateT IdxSet m Idx
Creates a new expr var id
renewIdAndExprIds :: Monad a => IdxTree -> Expr -> StateT IdxSet a (IdxTree, Expr)
Renew all expression ids and var ids in an idx pattern and expression
initExprVarIds :: Monad m => [(String, Idx)] -> Expr -> StateT IdxSet m Expr
Uses variable names to create new variable ids for all vars
initIdxTreeExpIds :: Monad m => IdxTree -> StateT IdxSet m IdxTree
Returns the same tree with the expression ids ialized
initIdxTreeVarIds :: Monad m => IdxTree -> StateT IdxSet m (IdxTree, [(String, Idx)])
Uses variable names to create new variable ids for all var ids
replaceIdxTreeIds :: Monad m => IdxTree -> StateT [(Idx, Idx)] (StateT IdxSet m) IdxTree
Replaces all expression ids with new ones |and creates new consistant variable ids.
replaceExprIds :: Monad m => Expr -> StateT [(Idx, Idx)] (StateT IdxSet m) Expr
Replaces all exp ids with new ones and create new |consistant variable ids.
visitExprTree :: Monad m => (a -> Expr -> m Expr) -> (a -> IdxTree -> m (IdxTree, a)) -> a -> Expr -> m Expr
visitIdxTree takes two functions,
visitExprTree takes three functions, one to process
|exprs, another process idx trees, and one to combine
|a
(environment) values, such that one
|can easily override basic expr visitor functionality.
|Note: to recursively visit, exprF must call visitExprTree exprF idxF
|unless expr is a leaf.
replaceExprIdsOnly :: Monad m => (Expr -> Bool) -> Expr -> StateT (Map Idx Idx) (StateT IdxSet m) Expr
Replaces all exp ids with new ones in exps for which the predicate holds, and leaves var ids as is.
class StructEq a where
Class for types that have structural equality defined on them
getLetVarExprIds :: Expr -> [(String, Idx)]
getLetVarExprIds gets the expression ids for all of the let vars |in the program.
countExprs :: (Expr -> Bool) -> Expr -> Int
countExprs predFun expr. Counts how many expressions match |predFun in expre.
isLeafExpr :: Expr -> Bool
getIdxTreeVars :: IdxTree -> [(String, Idx)]
getVarExprName :: Expr -> String
getExprById :: Idx -> Expr -> Maybe Expr
checkExpIdsUnique :: Monad m => String -> Expr -> m Expr
removeEmptyTups :: Expr -> Expr
getFreeExprVars :: Expr -> [(String, Idx)]
getVarExprIds :: Expr -> [(Idx, Idx)]
filterExprs :: (Expr -> Bool) -> Expr -> [Expr]
filterExprs pred e. Returns a list of all expressions in exp that match the predicate pred.
removeFunApps :: (Expr -> Bool) -> Expr -> Expr
removeFunApps pred expr. Returns expr where all fun apps for which |pred returns true have been removed (i.e. replaced by their argument exp).