monad-par- A library for parallel programming based on a monad



Some experimental support for OpenLists, which are streams in the Par monad that support constant-time append.



data OpenList a Source


Show a => Show (OpenList a)

OpenLists can only be printed properly in the Par monad. show on an open list will only give a hint -- what the first and last elements of the openlist are.

NFData a => NFData (OpenList a) 

empty :: OpenList aSource

An empty open list. Supports further extension.

singleton :: a -> Par (OpenList a)Source

A single element open list.

cons :: NFData a => a -> OpenList a -> Par (OpenList a)Source

Add an element to the front of an OpenList. Works irrespective | of whether the input is closed.

head :: OpenList a -> aSource

Head of an OpenList.

tail :: OpenList a -> Par (OpenList a)Source

Tail of an OpenList. Beware, if the list contains only one element (e.g. the result of tail will be null), it must be CLOSED for tail to work.

length :: Num t => OpenList a -> Par tSource

close :: NFData a => OpenList a -> Par (OpenList a)Source

Terminate a non-empty open list so that it cannot be extended further.

join :: NFData a => OpenList a -> OpenList a -> Par (OpenList a)Source

Destructive append operation.

toList :: NFData a => OpenList a -> Par [a]Source

Convert a CLOSED OpenList to a list.

fromList :: NFData a => [a] -> Par (OpenList a)Source

Convert a list to an OpenList, open to extension at the tail.

toLazyList :: OpenList a -> Par [a]Source

Asynchronously convert an OpenList to a lazy list. Returns immediately.

parMapM :: NFData a => (a1 -> Par a) -> OpenList a1 -> Par (OpenList a)Source

parBuild :: NFData a => InclusiveRange -> (Int -> a) -> Par (OpenList a)Source

Build an OpenList with a divide-and-conquer parallel strategy.

parBuildM :: NFData a => InclusiveRange -> (Int -> Par a) -> Par (OpenList a)Source

Build an OpenList with a divide-and-conquer parallel strategy, allowing nested parallelism in the per-element computation.

data IList a Source

An IList is the equivalent of a lazy list in the Par monad. The tail of the list is an IVar, which allows the list to be produced and consumed in parallel.




hd :: a
tl :: IVar (IList a)


NFData a => NFData (IList a)

To fully evaluate an IList means to evaluate both the head and tail. This does not evaluate the entire spine of the list of course, because the tail is an IVar.

newCell :: a -> Par (IList a)Source