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

Control.Monad.Par.OpenList

Description

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

Synopsis

Documentation

data OpenList a

Instances

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 a

An empty open list. Supports further extension.

singleton :: a -> Par (OpenList a)

A single element open list.

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

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

head :: OpenList a -> a

Head of an OpenList.

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

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 t

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

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

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

Destructive append operation.

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

Convert a CLOSED OpenList to a list.

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

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

toLazyList :: OpenList a -> Par [a]

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

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

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

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

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

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

data IList a

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.

Constructors

Null 
Cons 

Fields

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

Instances

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)