parallel-1.0.0.0: parallel programming libraryContentsIndex
Control.Parallel.Strategies
Portabilitynon-portable
Stabilityexperimental
Maintainerlibraries@haskell.org
Contents
Strategy Type, Application and Semantics
Basic Strategies
Strategic Function Application
Tuples
Lists: Parallel Strategies
Lists: Sequential Strategies
Arrays
Deprecated types and functions
Description

Parallel strategy combinators. See http://www.macs.hw.ac.uk/~dsg/gph/papers/html/Strategies/strategies.html for more information.

Original authors: Phil Trinder, Hans-Wolfgang Loidl, Kevin Hammond et al.

Synopsis
type Done = ()
type Strategy a = a -> Done
(>|) :: Done -> Done -> Done
(>||) :: Done -> Done -> Done
using :: a -> Strategy a -> a
demanding :: a -> Done -> a
sparking :: a -> Done -> a
r0 :: Strategy a
rwhnf :: Strategy a
class NFData a where
rnf :: Strategy a
($|) :: (a -> b) -> Strategy a -> a -> b
($||) :: (a -> b) -> Strategy a -> a -> b
(.|) :: (b -> c) -> Strategy b -> (a -> b) -> a -> c
(.||) :: (b -> c) -> Strategy b -> (a -> b) -> a -> c
(-|) :: (a -> b) -> Strategy b -> (b -> c) -> a -> c
(-||) :: (a -> b) -> Strategy b -> (b -> c) -> a -> c
seqPair :: Strategy a -> Strategy b -> Strategy (a, b)
parPair :: Strategy a -> Strategy b -> Strategy (a, b)
seqTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
parTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
parList :: Strategy a -> Strategy [a]
parListN :: Integral b => b -> Strategy a -> Strategy [a]
parListNth :: Int -> Strategy a -> Strategy [a]
parListChunk :: Int -> Strategy a -> Strategy [a]
parMap :: Strategy b -> (a -> b) -> [a] -> [b]
parFlatMap :: Strategy [b] -> (a -> [b]) -> [a] -> [b]
parZipWith :: Strategy c -> (a -> b -> c) -> [a] -> [b] -> [c]
seqList :: Strategy a -> Strategy [a]
seqListN :: Integral a => a -> Strategy b -> Strategy [b]
seqListNth :: Int -> Strategy b -> Strategy [b]
parBuffer :: Int -> Strategy a -> [a] -> [a]
seqArr :: Ix b => Strategy a -> Strategy (Array b a)
parArr :: Ix b => Strategy a -> Strategy (Array b a)
sPar :: a -> Strategy b
sSeq :: a -> Strategy b
data Assoc a b = (:=) a b
fstPairFstList :: NFData a => Strategy [(a, b)]
force :: NFData a => a -> a
sforce :: NFData a => a -> b -> b
Strategy Type, Application and Semantics
type Done = ()
type Strategy a = a -> Done
A strategy takes a value and returns a Done value to indicate that the specifed evaluation has been performed.
(>|) :: Done -> Done -> Done
Evaluates the first argument before the second.
(>||) :: Done -> Done -> Done
Evaluates the first argument in parallel with the second.
using :: a -> Strategy a -> a

Takes a value and a strategy, and applies the strategy to the value before returning the value. Used to express data-oriented parallelism. x `using` s is a projection on x, i.e. both:

a retraction
x `using` sx
idempotent
(x `using` s) `using` s = x `using` s
demanding :: a -> Done -> a
Evaluates the second argument before the first. Used to express control-oriented parallelism. The second argument is usually a strategy application.
sparking :: a -> Done -> a
Evaluates the second argument in parallel with the first. Used to express control-oriented parallelism. The second argument is usually a strategy application.
Basic Strategies
r0 :: Strategy a
Performs no evaluation of its argument.
rwhnf :: Strategy a
Reduces its argument to weak head normal form.
class NFData a where
Methods
rnf :: Strategy a
Reduces its argument to (head) normal form.
show/hide Instances
NFData Bool
NFData Char
NFData Double
NFData Float
NFData Int
NFData Int16
NFData Int32
NFData Int64
NFData Int8
NFData IntSet
NFData Integer
NFData Word16
NFData Word32
NFData Word64
NFData Word8
NFData ()
(NFData a, NFData b) => NFData (a, b)
(NFData a, NFData b, NFData c) => NFData (a, b, c)
(NFData a, NFData b, NFData c, NFData d) => NFData (a, b, c, d)
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5)
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6)
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7)
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8) => NFData (a1, a2, a3, a4, a5, a6, a7, a8)
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8, NFData a9) => NFData (a1, a2, a3, a4, a5, a6, a7, a8, a9)
(RealFloat a, NFData a) => NFData (Complex a)
NFData a => NFData (IntMap a)
NFData a => NFData (Maybe a)
(Integral a, NFData a) => NFData (Ratio a)
NFData a => NFData (Set a)
NFData a => NFData (Tree a)
NFData a => NFData [a]
(Ix a, NFData a, NFData b) => NFData (Array a b)
(NFData a, NFData b) => NFData (Assoc a b)
(NFData a, NFData b) => NFData (Either a b)
(NFData k, NFData a) => NFData (Map k a)
Strategic Function Application
($|) :: (a -> b) -> Strategy a -> a -> b
Sequential function application. The argument is evaluated using the given strategy before it is given to the function.
($||) :: (a -> b) -> Strategy a -> a -> b
Parallel function application. The argument is evaluated using the given strategy, in parallel with the function application.
(.|) :: (b -> c) -> Strategy b -> (a -> b) -> a -> c
Sequential function composition. The result of the second function is evaluated using the given strategy, and then given to the first function.
(.||) :: (b -> c) -> Strategy b -> (a -> b) -> a -> c
Parallel function composition. The result of the second function is evaluated using the given strategy, in parallel with the application of the first function.
(-|) :: (a -> b) -> Strategy b -> (b -> c) -> a -> c
Sequential inverse function composition, for those who read their programs from left to right. The result of the first function is evaluated using the given strategy, and then given to the second function.
(-||) :: (a -> b) -> Strategy b -> (b -> c) -> a -> c
Parallel inverse function composition, for those who read their programs from left to right. The result of the first function is evaluated using the given strategy, in parallel with the application of the second function.
Tuples
seqPair :: Strategy a -> Strategy b -> Strategy (a, b)
Apply two strategies to the elements of a pair sequentially from left to right.
parPair :: Strategy a -> Strategy b -> Strategy (a, b)
Apply two strategies to the elements of a pair in parallel.
seqTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
Apply three strategies to the elements of a triple in sequentially from left to right.
parTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
Apply three strategies to the elements of a triple in parallel.
Lists: Parallel Strategies
parList :: Strategy a -> Strategy [a]
Applies a strategy to every element of a list in parallel.
parListN :: Integral b => b -> Strategy a -> Strategy [a]
Applies a strategy to the first n elements of a list in parallel.
parListNth :: Int -> Strategy a -> Strategy [a]
Evaluates n elements of the spine of the argument list and applies the given strategy to the nth element (if there is one) in parallel with the result. E.g. parListNth 2 [e1, e2, e3] evaluates e3.
parListChunk :: Int -> Strategy a -> Strategy [a]
Splits a list into chunks (sub-sequences) of length n, and applies a strategy sequentially to the elements in each chunk. The chunks are evaluated in parallel. This is useful for increasing the grain size.
parMap :: Strategy b -> (a -> b) -> [a] -> [b]
Applies a function to each element of a list and and evaluates the result list in parallel, using the given strategy for each element.
parFlatMap :: Strategy [b] -> (a -> [b]) -> [a] -> [b]
Uses parMap to apply a list-valued function to each element of a list in parallel, and concatenates the results.
parZipWith :: Strategy c -> (a -> b -> c) -> [a] -> [b] -> [c]
Zips together two lists using a function, and evaluates the result list in parallel.
Lists: Sequential Strategies
seqList :: Strategy a -> Strategy [a]
Sequentially applies a strategy to each element of a list.
seqListN :: Integral a => a -> Strategy b -> Strategy [b]
Sequentially applies a strategy to the first n elements of a list.
seqListNth :: Int -> Strategy b -> Strategy [b]
Applies a strategy to the nth element of a list (if there is one) before returning the result. E.g. seqListNth 2 [e1, e2, e3] evaluates e3.
parBuffer :: Int -> Strategy a -> [a] -> [a]
Parallel n-buffer function added for the revised version of the strategies paper. parBuffer supersedes the older fringeList. It has the same semantics.
Arrays
seqArr :: Ix b => Strategy a -> Strategy (Array b a)
Apply a strategy to all elements of an array sequentially.
parArr :: Ix b => Strategy a -> Strategy (Array b a)
Apply a strategy to all elements of an array in parallel.
Deprecated types and functions
sPar :: a -> Strategy b

A strategy corresponding to par: x `par` e = e `using` sPar x.

sPar has been superceded by sparking. Replace e `using` sPar x with e `sparking` rwhnf x.

sSeq :: a -> Strategy b

A strategy corresponding to seq: x `seq` e = e `using` sSeq x.

sSeq has been superceded by demanding. Replace e `using` sSeq x with e `demanding` rwhnf x.

data Assoc a b
Constructors
(:=) a b
show/hide Instances
(NFData a, NFData b) => NFData (Assoc a b)
fstPairFstList :: NFData a => Strategy [(a, b)]
force :: NFData a => a -> a
sforce :: NFData a => a -> b -> b
Produced by Haddock version 0.8