LogicGrowsOnTrees-1.0.0.0.1: a parallel implementation of logic programming using distributed tree exploration

Safe HaskellNone

LogicGrowsOnTrees.Workload

Contents

Description

This module contains infrastructure for working with Workloads, which describe a portion of work to be performed by a worker.

Synopsis

Workload type and simple functions

data Workload Source

A Workload describes a portion of work to be performed by a worker; it consists of a Path to the subtree where the workload is located paired with a Checkpoint that indicates which parts of that subtree have already been explored.

Instances

Eq Workload 
Ord Workload

Workloads are ordered first by their depth (the length of the Path component), second by the value of the Path component itself, and finally by the value of the Checkpoint component. This ordering was chosen because there are times where it is nice to be able to conveniently order Workloads by depth.

Show Workload 
Serialize Workload 

entire_workload :: WorkloadSource

A Workload that consists of the entire tree.

workloadDepth :: Workload -> IntSource

The depth of the workload, equal to the length of the Path component.

Exploration functions

The functions in this section explore the part of a tree that is given by a Workload.

exploreTreeWithinWorkload :: Monoid α => Workload -> Tree α -> αSource

Explores the nodes in a pure tree given by a Workload, and sums over all the results in the leaves.

exploreTreeTWithinWorkload :: (Monad m, Monoid α) => Workload -> TreeT m α -> m αSource

Same as exploreTreeWithinWorkload but for an impure tree.

exploreTreeUntilFirstWithinWorkload :: Workload -> Tree α -> Maybe αSource

Explores the nodes in a pure tree given by a Workload until a result (i.e. a leaf) has been found; if a result has been found then it is returned wrapped in Just, otherwise Nothing is returned.

exploreTreeUntilFoundWithinWorkload :: Monoid α => (α -> Bool) -> Workload -> Tree α -> (α, Bool)Source

Explores the nodes in a pure tree given by a Workload, summing all results encountered (i.e., in the leaves) until the current partial sum satisfies the condition provided by the first parameter.

See exploreTreeUntilFound for more details.

exploreTreeTUntilFoundWithinWorkload :: (Monoid α, Monad m) => (α -> Bool) -> Workload -> TreeT m α -> m (α, Bool)Source

Same as exploreTreeUntilFoundWithinWorkload but for an impure tree.