Safe Haskell | None |
---|

This module store the interface between the evaluator and the manipulated graph.

- class (GraphPath rezPath, Eq a) => GraphWalker a rezPath | a -> rezPath where
- attribOf :: String -> a -> Maybe String
- nameOf :: a -> Maybe String
- childrenOf :: (IOMockable m, Monad m) => a -> m [a]
- valueOf :: a -> String
- indirectLinks :: a -> [rezPath]
- accessGraph :: (IOMockable m, Functor m, Monad m) => Loggers m -> rezPath -> m (AccessResult a rezPath)
- rawAccess :: (IOMockable m, Functor m, Monad m) => Loggers m -> rezPath -> m (AccessResult a rezPath)
- isHistoryMutable :: a -> Bool
- deepValueOf :: (IOMockable m, Functor m, Monad m) => a -> m String

- class Show a => GraphPath a where
- (<//>) :: a -> a -> a
- importPath :: String -> Maybe a
- dumpDataAtPath :: (Monad m, IOMockable m) => Loggers m -> a -> m ()
- localizePath :: a -> FilePath

- data AccessResult a rezPath
- = Result rezPath a
- | DataBlob rezPath ByteString
- | AccessError

- type Logger m = String -> m ()
- type Loggers m = (Logger m, Logger m, Logger m)
- type NodePath a = [(a, Int)]
- descendants :: (IOMockable m, Monad m, GraphWalker a r) => a -> m [(a, [(a, Int)])]
- findNamed :: (Functor m, Monad m, IOMockable m, GraphWalker a r) => String -> a -> m [(a, [(a, Int)])]
- findFirstNamed :: (Functor m, Monad m, IOMockable m, GraphWalker a r) => String -> [a] -> m (Maybe (a, [(a, Int)]))
- pureDescendants :: (a -> [a]) -> a -> [(a, [(a, Int)])]
- findNamedPure :: GraphWalker a r => (a -> [a]) -> String -> a -> [(a, [(a, Int)])]
- findFirstNamedPure :: GraphWalker a r => (a -> [a]) -> String -> [a] -> Maybe (a, [(a, Int)])

# Classes

class (GraphPath rezPath, Eq a) => GraphWalker a rezPath | a -> rezPath whereSource

The aim of this typeclass is to permit the use of different html/xml parser if if the first one is found to be bad. All the logic should use this interface.

Minimal implementation : everything but deepValueOf.

attribOf :: String -> a -> Maybe StringSource

Get back an attribute of the node if it exists

nameOf :: a -> Maybe StringSource

If the current node is named, return it's name, otherwise return Nothing.

childrenOf :: (IOMockable m, Monad m) => a -> m [a]Source

Get all the children of the current node.

Retrieve the value of the tag (textual)

indirectLinks :: a -> [rezPath]Source

Retrieve all the indirectly linked content of a node, can be used for element like an HTML link or an linked image/obj

accessGraph :: (IOMockable m, Functor m, Monad m) => Loggers m -> rezPath -> m (AccessResult a rezPath)Source

The idea behind link following. The graph engine may have another name for the resource, so an updated name can be given. The given function is there to log information, the second is to log errors

rawAccess :: (IOMockable m, Functor m, Monad m) => Loggers m -> rezPath -> m (AccessResult a rezPath)Source

Same as accessGraph, but don't try to return a structured result, only blobs.

isHistoryMutable :: a -> BoolSource

Tell if the history associated is fixed or not. If the history is not fixed and can change (if you are querying the filesystem for example, it should return False)

deepValueOf :: (IOMockable m, Functor m, Monad m) => a -> m StringSource

Like value of, but force the node to collect the value of all it's children in the process.

class Show a => GraphPath a whereSource

Represent indirect links or links which necessitate the use of the IO monad to walk around the graph.

Combine two path togethers, you can think of the / operator for an equivalence.

importPath :: String -> Maybe aSource

conversion to be used to import path from attributes/document (not really well specified).

dumpDataAtPath :: (Monad m, IOMockable m) => Loggers m -> a -> m ()Source

Move semantic, try to dump the pointed resource to the current folder.

localizePath :: a -> FilePathSource

Given a graphpath, transform it to a filepath which can be used to store a node.

# Commodity types

data AccessResult a rezPath Source

Result of indirect access demand.

Result rezPath a | We got a result and parsed it, maybe it has changed of location, so we give back the location |

DataBlob rezPath ByteString | We got something, but we can't interpret it, so we return a binary blob. |

AccessError | Cannot access the resource. |

type Logger m = String -> m ()Source

Type used to propagate different logging level across the software.

type NodePath a = [(a, Int)]Source

Represent the path used to find the node from the starting point of the graph.

# Helper functions.

descendants :: (IOMockable m, Monad m, GraphWalker a r) => a -> m [(a, [(a, Int)])]Source

Return a list of all the children/linked node of a given node. The given node is not included in the list. A list of node with the taken path is returned.

findNamed :: (Functor m, Monad m, IOMockable m, GraphWalker a r) => String -> a -> m [(a, [(a, Int)])]Source

Given a tag and a name, retrieve the first matching tags in the hierarchy. It must return the list of ancestors permitting the acess to the path used to find children

the returned list must contain : the node itself if it match the name, and all the children containing the good name.

findFirstNamed :: (Functor m, Monad m, IOMockable m, GraphWalker a r) => String -> [a] -> m (Maybe (a, [(a, Int)]))Source

Return the first found node if any.

# Helper functions without monadic interface.

pureDescendants :: (a -> [a]) -> a -> [(a, [(a, Int)])]Source

like `descendants`

, but without the monadic interface.

findNamedPure :: GraphWalker a r => (a -> [a]) -> String -> a -> [(a, [(a, Int)])]Source

Like `findNamed`

but without the monadic interface.

findFirstNamedPure :: GraphWalker a r => (a -> [a]) -> String -> [a] -> Maybe (a, [(a, Int)])Source

Like `findFirstNamed`

, but without the monadic interface.