| parallel-1.0.0.1: parallel programming library | Source code | Contents | Index
Control.Parallel.Strategies |
Portability | non-portable
Stability | experimental
Maintainer | libraries@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 = () | Source
type Strategy a = a -> Done | Source
A strategy takes a value and returns a `Done` value to indicate that the specifed evaluation has been performed.
(>|) :: Done -> Done -> Done | Source
Evaluates the first argument before the second.
(>||) :: Done -> Done -> Done | Source
Evaluates the first argument in parallel with the second.
using :: a -> Strategy a -> a | Source
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` s` ⊑ `x` idempotent `(x `using` s) `using` s` = `x `using` s`
demanding :: a -> Done -> a | Source
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 | Source
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 | Source
Performs no evaluation of its argument.
rwhnf :: Strategy a | Source
Reduces its argument to weak head normal form.
class NFData a where | Source
Methods
rnf :: Strategy a | Source
Reduces its argument to (head) normal form.
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 | Source
Sequential function application. The argument is evaluated using the given strategy before it is given to the function.
($||) :: (a -> b) -> Strategy a -> a -> b | Source
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 | Source
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 | Source
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 | Source
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 | Source
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 (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] | 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 list-valued 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
Applies a strategy to the nth element of list when the head is demanded. More precisely: semantics: `parBuffer n s = id :: [a] -> [a]` dynamic behaviour: evalutates the nth element of the list when the head is demanded. The idea is to provide a `rolling buffer' of length n. `parBuffer` has been added for the revised version of the strategies paper and supersedes the older `fringeList`.
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
sPar :: a -> Strategy b | Source
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 | Source
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 | Source
Constructors
(:=) a b |
Instances
(NFData a, NFData b) => NFData (Assoc a b)
fstPairFstList :: NFData a => Strategy [(a, b)] | Source
force :: NFData a => a -> a | Source
sforce :: NFData a => a -> b -> b | Source
Produced by Haddock version 0.9