Stability | experimental |
---|---|
Maintainer | developer@flocc.net |
Safe Haskell | None |
For more information please see http://www.flocc.net/
- data Kind
- type Id = String
- type IdTree = Tree Id
- type Code = String
- data Val m
- isVarV :: Val t -> Bool
- isTyV :: Val t -> Bool
- fromIntVal :: Monad m => Val m -> Int
- fromTreeVal :: Monad m => Val m -> Tree (Val m)
- fromFunNode :: Monad m => NodeTy -> Val m
- fromTyVal :: Monad m => String -> Val m -> Ty
- mergeVals :: Monad m => String -> Val m -> Val m -> Val m
- tidyTy :: Ty -> Ty
- tidyVal :: Monad m => Val m -> Val m
- type ValEnv m = Map Id (Val m)
- emptyValEnv :: Map k a
- renderVal :: Monad m => String -> String -> Val m -> Code
- applyTem :: Monad m => String -> StrTem -> [(Id, Val m)] -> Code
- lookupVal :: Monad m => String -> Id -> ValEnv m -> Val m
- lookupValMaybe :: Monad m => Id -> ValEnv m -> Maybe (Val m)
- varVal :: Monad m => String -> Val m -> (Ty, IdTree)
- lookupSubVal :: Monad m => String -> Val m -> TreePath -> Val m
- replaceSubVal :: Monad m => TreePath -> Val m -> Val m -> Val m
- alterSubVal :: Monad m => TreePath -> Val m -> Maybe (Val m) -> Maybe (Val m)
- data OrdVal
- isVarOV :: OrdVal -> Bool
- toOrdVal :: Monad m => Val m -> OrdVal
- fromOrdVal :: Monad m => OrdVal -> Val m
- type ValMap m = Map (Tree OrdVal) (Val m)
- emptyValMap :: Map k a
- data GenState m = GenState {
- genGraphs :: [Graph]
- genCurrentNode :: NodeId
- genCurrentInt :: Int
- genTemEnvs :: NodeEnv (ValEnv m)
- genObjMembers :: NodeEnv (ValEnv m)
- genOutBuffs :: Map Id Code
- genGlobals :: Map String (ValMap m)
- genDebugOut :: String
- genConsts :: GenConsts m
- type GenM m = StateT (GenState m) m ()
- type GenM1 m a = StateT (GenState m) m a
- type Template m = Ty -> NodeTreeEx -> GenM m
- type Templates m = Map Id (Template m)
- type Generator m = [Val m] -> GenM1 m (Val m)
- type Generators m = Map Id (Generator m)
- data GenConsts m = GenConsts {
- globTypes :: NodeEnv Ty
- globTemplates :: Templates m
- globGenerators :: Generators m
- globNumTopDims :: Int
- type TemplateProc m = Tree (Val m) -> GenM m
- getTemplateName :: Monad m => GenM1 m Id
- getNodeDesc :: Monad m => NodeId -> GenM1 m Id
- genError :: Monad m => String -> GenM1 m a
- genTrace :: Monad m => String -> GenM m
- assertM :: Monad m => GenM1 m Bool -> String -> GenM m
- pushGraph :: Monad m => Graph -> GenM1 m [Graph]
- popGraph :: Monad m => GenM1 m Graph
- newInt :: Monad m => GenM1 m Int
- skipInts :: Monad m => Int -> GenM m
- createNewNodeIds :: Monad m => Graph -> GenM1 m (IntMap NodeId)
- varToTreeVars :: Monad m => Val m -> Maybe (Tree (Val m))
- zipValTrees :: Monad m => IdTree -> Tree (Val m) -> Tree (Id, Val m)
- expandIdTreeL :: IdTree -> Ty -> LabelledTree (Maybe Id) Id
- expandIdTree :: IdTree -> Ty -> IdTree
- partitionByTy :: Monad m => [NodeId] -> GenM1 m [[NodeId]]
Documentation
data Val m
fromIntVal :: Monad m => Val m -> Int
fromTreeVal :: Monad m => Val m -> Tree (Val m)
fromTreeVal val. If val is a TreeV val, returns the |value it encloses, otherwise throws an error.
fromFunNode :: Monad m => NodeTy -> Val m
fromFunNode funNode. Takes a FunNd and returns the |same value as a GraphV.
mergeVals :: Monad m => String -> Val m -> Val m -> Val m
mergeVals v1 v2. Tries to merge v1 and v2. Only |works if they are both code values.
emptyValEnv :: Map k a
lookupVal :: Monad m => String -> Id -> ValEnv m -> Val m
lookups up a value from a ValEnv and throws error if it doesn't |exist.
varVal :: Monad m => String -> Val m -> (Ty, IdTree)
varVal errMsg val returns the type and idtree of a val if it is a var |or throws the error message if it is not.
lookupSubVal :: Monad m => String -> Val m -> TreePath -> Val m
lookupSubVal val path. Looks up the sub var, or sub type |found using the path. Throws an error if the path is non |null and the val doesn't contain a tree, or doesn't contain |a node for the path.
replaceSubVal :: Monad m => TreePath -> Val m -> Val m -> Val m
replaceSubVal path newSubVal oldVal. If newSubVal and oldVal |are values with a tree structures (vals or types), this returns |oldVal with the node at path replaced with newSubVal.
alterSubVal :: Monad m => TreePath -> Val m -> Maybe (Val m) -> Maybe (Val m)
alterSubVal path newSubVal oldVal. Replaces the sub val at path in |oldVal with newSubVal. Throws error if path doesn't exist in oldVal |or if path is non-empty and oldVal is Nothing.
data OrdVal
Values that can be used as Map keys.
toOrdVal :: Monad m => Val m -> OrdVal
toOrdVal val. Returns the OrdVal version of val, or |throws an error if val is a graph or function.
fromOrdVal :: Monad m => OrdVal -> Val m
fromOrdVal oval. Returns the Val version of oval.
emptyValMap :: Map k a
data GenState m
The code generator monad state object
GenState | |
|
type Template m = Ty -> NodeTreeEx -> GenM m
A template
type Generators m = Map Id (Generator m)
data GenConsts m
Types, and templates etc
GenConsts | |
|
type TemplateProc m = Tree (Val m) -> GenM m
getTemplateName :: Monad m => GenM1 m Id
getTemplateName. Returns the function name |of the currently
getNodeDesc :: Monad m => NodeId -> GenM1 m Id
getTemplateName. Returns the function name |of the currently
pushGraph :: Monad m => Graph -> GenM1 m [Graph]
pushGraph graph. Pushes the graph onto the stack |and returns the new stack list.
newInt :: Monad m => GenM1 m Int
newInt generates a fresh integer, by incrementing the current int |in the generator monad.
skipInts :: Monad m => Int -> GenM m
skipInts n. If n is greater than the current int, makes the current |int n.
createNewNodeIds :: Monad m => Graph -> GenM1 m (IntMap NodeId)
createNewNodeIds graph. Returns a Map of old node ids |to new node ids for all the node ids in the graph.
varToTreeVars :: Monad m => Val m -> Maybe (Tree (Val m))
varToTreeVars varVal. If varVal is a VarV with a tuple of |types and lists, this decomposes that tuple (one level) into a tree of |var vals.
zipValTrees :: Monad m => IdTree -> Tree (Val m) -> Tree (Id, Val m)
zipTrees treeA treeB. Assuming treeA is a subset of treeB |returns a new tree with all children in b dangling from those |in a. Throws error otherwise.
expandIdTreeL :: IdTree -> Ty -> LabelledTree (Maybe Id) Id
expandIdTreeL type idTree. Expands the idTree so it is the |same shape as the type tree, i.e. there is an id label (which may |be a struct reference) for all the original leaf nodes, |and all nodes below them.
expandIdTree :: IdTree -> Ty -> IdTree
expandIdTree type idTree. Expands the idTree so it is the |same shape as the type tree, i.e. there is an id (which may |be a struct reference) for each leaf type.
partitionByTy :: Monad m => [NodeId] -> GenM1 m [[NodeId]]