Portability  nonportable 

Stability  experimental 
Maintainer  libraries@haskell.org 
Parallel strategy combinators. See http://www.macs.hw.ac.uk/~dsg/gph/papers/html/Strategies/strategies.html for more information.
Original authors: Phil Trinder, HansWolfgang Loidl, Kevin Hammond et al.
 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
 ($) :: (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 Strategy a = a > DoneSource
A strategy takes a value and returns a Done
value to indicate that
the specifed evaluation has been performed.
using :: a > Strategy a > aSource
Takes a value and a strategy, and applies the strategy to the
value before returning the value. Used to express dataoriented
parallelism. x `using` s
is a projection on x
, i.e. both:
 a retraction

x `using` s
⊑x
 idempotent

(x `using` s) `using` s
=x `using` s
demanding :: a > Done > aSource
Evaluates the second argument before the first. Used to express controloriented parallelism. The second argument is usually a strategy application.
sparking :: a > Done > aSource
Evaluates the second argument in parallel with the first. Used to express controloriented parallelism. The second argument is usually a strategy application.
Basic Strategies
Strategic Function Application
($) :: (a > b) > Strategy a > a > bSource
Sequential function application. The argument is evaluated using the given strategy before it is given to the function.
($) :: (a > b) > Strategy a > a > bSource
Parallel function application. The argument is evaluated using the given strategy, in parallel with the function application.
(.) :: (b > c) > Strategy b > (a > b) > a > cSource
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 > cSource
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 > cSource
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 > cSource
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)Source
Apply two strategies to the elements of a pair sequentially from left to right.
parPair :: Strategy a > Strategy b > Strategy (a, b)Source
Apply two strategies to the elements of a pair in parallel.
seqTriple :: Strategy a > Strategy b > Strategy c > Strategy (a, b, c)Source
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)Source
Apply three strategies to the elements of a triple in parallel.
Lists: Parallel Strategies
parList :: Strategy a > Strategy [a]Source
Applies a strategy to every element of a list in parallel.
parListN :: Integral b => b > Strategy a > Strategy [a]Source
Applies a strategy to the first n
elements of a list in parallel.
parListNth :: Int > Strategy a > Strategy [a]Source
Evaluates n
elements of the spine of the argument list and applies
the given strategy to the n
th 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]Source
Splits a list into chunks (subsequences) 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]Source
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]Source
Uses parMap
to apply a listvalued function to each
element of a list in parallel, and concatenates the results.
parZipWith :: Strategy c > (a > b > c) > [a] > [b] > [c]Source
Zips together two lists using a function, and evaluates the result list in parallel.
Lists: Sequential Strategies
seqList :: Strategy a > Strategy [a]Source
Sequentially applies a strategy to each element of a list.
seqListN :: Integral a => a > Strategy b > Strategy [b]Source
Sequentially applies a strategy to the first n elements of a list.
seqListNth :: Int > Strategy b > Strategy [b]Source
Applies a strategy to the n
th 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]Source
Parallel nbuffer 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)Source
Apply a strategy to all elements of an array sequentially.
parArr :: Ix b => Strategy a > Strategy (Array b a)Source
Apply a strategy to all elements of an array in parallel.
Deprecated types and functions
fstPairFstList :: NFData a => Strategy [(a, b)]Source