Safe HaskellNone



For more information please see http://www.flocc.net/



data Kind




type Id = String

type IdTree = Tree Id

type Code = String

data Val m


Monad m => Eq (Val m) 
Show (Val m) 

isVarV :: Val t -> Bool

isTyV :: Val t -> Bool

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.

fromTyVal :: Monad m => String -> Val m -> Ty

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.

tidyTy :: Ty -> Ty

tidyVal :: Monad m => Val m -> Val m

tidyVal val. Removes redundant tuples from all |nested trees.

type ValEnv m = Map Id (Val m)

renderVal :: Monad m => String -> String -> Val m -> Code

Convert a val to code

applyTem :: Monad m => String -> StrTem -> [(Id, Val m)] -> Code

lookupVal :: Monad m => String -> Id -> ValEnv m -> Val m

lookups up a value from a ValEnv and throws error if it doesn't |exist.

lookupValMaybe :: Monad m => Id -> ValEnv m -> Maybe (Val m)

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.

type ValMap m = Map (Tree OrdVal) (Val m)

Map from ord values to values

data GenState m

The code generator monad state object


type GenM m = StateT (GenState m) m ()

The code generator monad

type GenM1 m a = StateT (GenState m) m a

type Template m = Ty -> NodeTreeEx -> GenM m

A template

type Templates m = Map Id (Template m)

A map of templates for function

type Generator m = [Val m] -> GenM1 m (Val m)

A generator function (generates builtins)

type Generators m = Map Id (Generator m)

data GenConsts m

Types, and templates etc


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

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]

pushGraph graph. Pushes the graph onto the stack |and returns the new stack list.

popGraph :: Monad m => GenM1 m Graph

popGraph. Removes the head graph off the stack and |returns it.

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.