Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell98 |

A tree of computation

- data Tree a
- data Label
- requireAll :: [Tree a] -> Tree a
- requireAny :: [Tree a] -> Tree a
- tryAll :: [Tree a] -> Tree a
- evalTree :: forall a. Monoid a => (a -> Bool) -> Tree (Promise a) -> IO (a, a)
- watchTree :: Monoid a => (a -> Bool) -> Tree (Promise a) -> IO (TChan a, DTVar (Tree (PromiseResult a)))
- interleave :: Tree a -> [a]
- interleave' :: Tree a -> [a]
- showTree :: Show a => Tree a -> String

# Trees

Both/Either-trees

Both/Either labels

# Creating trees

requireAll :: [Tree a] -> Tree a Source

All of these must succeed

requireAny :: [Tree a] -> Tree a Source

Any of these must succeed

# Evaluating trees

evalTree :: forall a. Monoid a => (a -> Bool) -> Tree (Promise a) -> IO (a, a) Source

Evaluates a tree of promises, cutting of unnecessary branches, given that some other thread(s) evaluates the promises.

The first result is the failures, then the actual result comes

watchTree :: Monoid a => (a -> Bool) -> Tree (Promise a) -> IO (TChan a, DTVar (Tree (PromiseResult a))) Source

Assuming some other thread(s) evaluate the promises in the tree, this gives
a live view of the progress, and cancels unnecessary subtrees (due to `Either`

).

The first argument is a way to deem promises with results as failures. `(== mempty)` or (const False) could be good alternatives. These failures are sent to the TChan.

# Scheduling

interleave :: Tree a -> [a] Source

A simple scheduling (see `workers`

)

interleave' :: Tree a -> [a] Source

A somewhat smarter scheduling (see `workers`

)