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

Safe HaskellNone
LanguageHaskell98

Control.Monad.Par.Scheds.TraceInternal

Description

This module exposes the internals of the Par monad so that you can build your own scheduler or other extensions. Do not use this module for purposes other than extending the Par monad with new functionality.

Synopsis

Documentation

data Trace Source #

Constructors

Get (IVar a) (a -> Trace) 
Put (IVar a) a Trace 
New (IVarContents a) (IVar a -> Trace) 
Fork Trace Trace 
Done 
Yield Trace 
LiftIO (IO a) (a -> Trace) 

data Sched Source #

Constructors

Sched 

Fields

newtype Par a Source #

Constructors

Par 

Fields

Instances
Monad Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

(>>=) :: Par a -> (a -> Par b) -> Par b #

(>>) :: Par a -> Par b -> Par b #

return :: a -> Par a #

fail :: String -> Par a #

Functor Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

fmap :: (a -> b) -> Par a -> Par b #

(<$) :: a -> Par b -> Par a #

MonadFix Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

mfix :: (a -> Par a) -> Par a #

Applicative Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

pure :: a -> Par a #

(<*>) :: Par (a -> b) -> Par a -> Par b #

liftA2 :: (a -> b -> c) -> Par a -> Par b -> Par c #

(*>) :: Par a -> Par b -> Par b #

(<*) :: Par a -> Par b -> Par a #

ParFuture IVar Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.Trace

Methods

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

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

get :: IVar a -> Par a #

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

ParIVar IVar Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.Trace

Methods

fork :: Par () -> Par () #

new :: Par (IVar a) #

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

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

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

newFull_ :: a -> Par (IVar a) #

newtype IVar a Source #

Constructors

IVar (IORef (IVarContents a)) 
Instances
ParFuture IVar Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.Trace

Methods

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

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

get :: IVar a -> Par a #

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

ParFuture IVar ParIO Source # 
Instance details

Defined in Control.Monad.Par.IO

Methods

spawn :: NFData a => ParIO a -> ParIO (IVar a) #

spawn_ :: ParIO a -> ParIO (IVar a) #

get :: IVar a -> ParIO a #

spawnP :: NFData a => a -> ParIO (IVar a) #

ParIVar IVar Par Source # 
Instance details

Defined in Control.Monad.Par.Scheds.Trace

Methods

fork :: Par () -> Par () #

new :: Par (IVar a) #

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

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

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

newFull_ :: a -> Par (IVar a) #

ParIVar IVar ParIO Source # 
Instance details

Defined in Control.Monad.Par.IO

Methods

fork :: ParIO () -> ParIO () #

new :: ParIO (IVar a) #

put :: NFData a => IVar a -> a -> ParIO () #

put_ :: IVar a -> a -> ParIO () #

newFull :: NFData a => a -> ParIO (IVar a) #

newFull_ :: a -> ParIO (IVar a) #

Eq (IVar a) Source #

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

Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

(==) :: IVar a -> IVar a -> Bool #

(/=) :: IVar a -> IVar a -> Bool #

NFData (IVar a) Source # 
Instance details

Defined in Control.Monad.Par.Scheds.TraceInternal

Methods

rnf :: IVar a -> () #

data IVarContents a Source #

Constructors

Full a 
Empty 
Blocked [a -> Trace] 

sched :: Bool -> Sched -> Trace -> IO () Source #

The main scheduler loop.

runPar :: Par a -> a Source #

Run a parallel, deterministic computation and return its result.

Note: you must NOT return an IVar in the output of the parallel computation. This is unfortunately not enforced, as it is with runST or with newer libraries that export a Par monad, such as lvish.

runParIO :: Par a -> IO a Source #

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

Returning any value containing IVar is still disallowed, as it can compromise type safety.

runParAsync :: Par a -> a Source #

An asynchronous version in which the main thread of control in a Par computation can return while forked computations still run in the background.

new :: Par (IVar a) Source #

Creates a new IVar

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

Creates a new IVar that contains a value

newFull_ :: a -> Par (IVar a) Source #

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

get :: IVar a -> Par a Source #

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

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

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

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

Put a value into an 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_.

yield :: Par () Source #

Allows other parallel computations to progress. (should not be necessary in most cases).

fixPar :: (a -> Par a) -> Par a Source #

Take the monadic fixpoint of a Par computation. This is the definition of mfix for Par. Throws FixParException if the result is demanded strictly within the computation.