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

Safe Haskell | None

Control.Monad.Par.OpenList

Description

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

Synopsis

- data OpenList a
- empty :: OpenList a
- singleton :: a -> Par (OpenList a)
- cons :: NFData a => a -> OpenList a -> Par (OpenList a)
- head :: OpenList a -> a
- tail :: OpenList a -> Par (OpenList a)
- length :: Num t => OpenList a -> Par t
- close :: NFData a => OpenList a -> Par (OpenList a)
- join :: NFData a => OpenList a -> OpenList a -> Par (OpenList a)
- toList :: NFData a => OpenList a -> Par [a]
- fromList :: NFData a => [a] -> Par (OpenList a)
- toLazyList :: OpenList a -> Par [a]
- parMapM :: NFData a => (a1 -> Par a) -> OpenList a1 -> Par (OpenList a)
- parBuild :: NFData a => InclusiveRange -> (Int -> a) -> Par (OpenList a)
- parBuildM :: NFData a => InclusiveRange -> (Int -> Par a) -> Par (OpenList a)
- openlist_tests :: Test
- chaintest :: Int -> Par (IList Int)
- async_test :: IO ()
- lazy_chaintest :: Int -> Par [Int]
- data IList a
  - = Null
  - | Cons {
    - hd :: a
    - tl :: IVar (IList a)
    }
- newCell :: a -> Par (IList a)

# Documentation

data OpenList a Source

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 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.

openlist_tests :: Test Source

chaintest :: Int -> Par (IList Int)Source

async_test :: IO ()Source

lazy_chaintest :: Int -> Par [Int]Source

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.

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)Source