monad-par-extras-0.3.3: Combinators and extra features for Par monads

Safe HaskellSafe
LanguageHaskell98

Control.Monad.Par.State

Contents

Description

This module provides a notion of (Splittable) State that is compatible with any Par monad.

This module provides instances that make StateT-transformed monads into valid Par monads.

Synopsis

Documentation

class SplittableState a where #

A type in SplittableState is meant to be added to a Par monad using StateT. It works like any other state except at fork points, where the runtime system splits the state using splitState.

Common examples for applications of SplittableState would include (1) routing a splittable random number generator through a parallel computation, and (2) keeping a tree-index that locates the current computation within the binary tree of forks. Also, it is possible to simply duplicate the state at all fork points, enabling "thread local" copies of the state.

The limitation of this approach is that the splitting method is fixed, and the same at all fork points.

Minimal complete definition

splitState

Methods

splitState :: a -> (a, a) #

Orphan instances

(SplittableState s, ParFuture fut p) => ParFuture fut (StateT s p) #

Adding State to a ParFuture monad yield s another ParFuture monad.

Methods

spawn :: NFData a => StateT s p a -> StateT s p (fut a) #

spawn_ :: StateT s p a -> StateT s p (fut a) #

get :: fut a -> StateT s p a #

spawnP :: NFData a => a -> StateT s p (fut a) #

(SplittableState s, ParFuture fut p) => ParFuture fut (StateT s p) #

Adding State to a ParFuture monad yields another ParFuture monad.

Methods

spawn :: NFData a => StateT s p a -> StateT s p (fut a) #

spawn_ :: StateT s p a -> StateT s p (fut a) #

get :: fut a -> StateT s p a #

spawnP :: NFData a => a -> StateT s p (fut a) #

(SplittableState s, ParIVar iv p) => ParIVar iv (StateT s p) #

Likewise, adding State to a ParIVar monad yield s another ParIVar monad.

Methods

fork :: StateT s p () -> StateT s p () #

new :: StateT s p (iv a) #

put :: NFData a => iv a -> a -> StateT s p () #

put_ :: iv a -> a -> StateT s p () #

newFull :: NFData a => a -> StateT s p (iv a) #

newFull_ :: a -> StateT s p (iv a) #

(SplittableState s, ParIVar iv p) => ParIVar iv (StateT s p) #

Likewise, adding State to a ParIVar monad yield s another ParIVar monad.

Methods

fork :: StateT s p () -> StateT s p () #

new :: StateT s p (iv a) #

put :: NFData a => iv a -> a -> StateT s p () #

put_ :: iv a -> a -> StateT s p () #

newFull :: NFData a => a -> StateT s p (iv a) #

newFull_ :: a -> StateT s p (iv a) #