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

Safe HaskellNone
LanguageHaskell98

Control.Monad.Par.Scheds.Trace

Description

This is the scheduler described in the paper "A Monad for Deterministic Parallelism". It is based on a lazy Trace data structure that separates the scheduler from the Par monad method implementations.

Synopsis

Documentation

runPar :: Par a -> a

runParIO :: Par a -> IO a

A version that avoids an internal unsafePerformIO for calling contexts that are already in the IO monad.

fork :: Par () -> Par ()

data IVar a

Instances

ParFuture IVar Par 
ParFuture IVar ParIO 
ParIVar IVar Par 
ParIVar IVar ParIO 
Eq (IVar a)

Equality for IVars is physical equality, as with other reference types.

NFData (IVar a) 

new :: Par (IVar a)

creates a new IVar

newFull :: NFData a => a -> Par (IVar a)

creates a new IVar that contains a value

newFull_ :: a -> Par (IVar a)

creates a new IVar that contains a value (head-strict only)

get :: IVar a -> Par a

read the value in a IVar. The get can only return when the value has been written by a prior or parallel put to the same IVar.

put :: NFData a => IVar a -> a -> Par ()

put a value into a IVar. Multiple puts to the same IVar are not allowed, and result in a runtime error.

put fully evaluates its argument, which therefore must be an instance of NFData. The idea is that this forces the work to happen when we expect it, rather than being passed to the consumer of the IVar and performed later, which often results in less parallelism than expected.

Sometimes partial strictness is more appropriate: see put_.

put_ :: IVar a -> a -> Par ()

like put, but only head-strict rather than fully-strict.

spawn :: NFData a => Par a -> Par (IVar a)

spawn_ :: Par a -> Par (IVar a)

spawnP :: NFData a => a -> Par (IVar a)