-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | parallel programming library
--
-- This package provides a library for parallel programming.
@package parallel
@version 1.1.0.1
-- | Parallel Constructs
module Control.Parallel
-- | Indicates that it may be beneficial to evaluate the first argument in
-- parallel with the second. Returns the value of the second argument.
--
-- a par b is exactly equivalent semantically to
-- b.
--
-- par is generally used when the value of a is likely
-- to be required later, but not immediately. Also it is a good idea to
-- ensure that a is not a trivial computation, otherwise the
-- cost of spawning it in parallel overshadows the benefits obtained by
-- running it in parallel.
--
-- Note that actual parallelism is only supported by certain
-- implementations (GHC with the -threaded option, and GPH, for
-- now). On other implementations, par a b = b.
par :: a -> b -> b
-- | Semantically identical to seq, but with a subtle operational
-- difference: seq is strict in both its arguments, so the
-- compiler may, for example, rearrange a seq b into
-- b seq a seq b. This is normally no problem when
-- using seq to express strictness, but it can be a problem when
-- annotating code for parallelism, because we need more control over the
-- order of evaluation; we may want to evaluate a before
-- b, because we know that b has already been sparked
-- in parallel with par.
--
-- This is why we have pseq. In contrast to seq,
-- pseq is only strict in its first argument (as far as the
-- compiler is concerned), which restricts the transformations that the
-- compiler can do, and ensures that the user can retain control of the
-- evaluation order.
pseq :: a -> b -> b
-- | Evaluates its first argument to head normal form, and then returns its
-- second argument as the result.
seq :: a -> b -> b
-- | 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.
module Control.Parallel.Strategies
type Done = ()
-- | A strategy takes a value and returns a Done value to indicate
-- that the specifed evaluation has been performed.
type Strategy a = a -> Done
-- | Evaluates the first argument before the second.
(>|) :: Done -> Done -> Done
-- | Evaluates the first argument in parallel with the second.
(>||) :: Done -> Done -> Done
-- | 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
--
using :: a -> Strategy a -> a
-- | Evaluates the second argument before the first. Used to express
-- control-oriented parallelism. The second argument is usually a
-- strategy application.
demanding :: 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.
sparking :: a -> Done -> a
-- | Performs no evaluation of its argument.
r0 :: Strategy a
-- | Reduces its argument to weak head normal form.
rwhnf :: Strategy a
class NFData a
rnf :: NFData a => Strategy a
-- | 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.
($||) :: (a -> b) -> Strategy a -> a -> b
-- | 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.
(.||) :: (b -> c) -> Strategy b -> (a -> b) -> (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.
(-||) :: (a -> b) -> Strategy b -> (b -> c) -> (a -> c)
-- | Apply two strategies to the elements of a pair sequentially from left
-- to right.
seqPair :: Strategy a -> Strategy b -> Strategy (a, b)
-- | Apply two strategies to the elements of a pair in parallel.
parPair :: Strategy a -> Strategy b -> Strategy (a, b)
-- | Apply three strategies to the elements of a triple in sequentially
-- from left to right.
seqTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
-- | Apply three strategies to the elements of a triple in parallel.
parTriple :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c)
-- | Applies a strategy to every element of a list in parallel.
parList :: Strategy a -> Strategy [a]
-- | Applies a strategy to the first n elements of a list in
-- parallel.
parListN :: Integral b => b -> 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.
parListNth :: 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.
parListChunk :: Int -> Strategy a -> Strategy [a]
-- | Applies a function to each element of a list and and evaluates the
-- result list in parallel, using the given strategy for each element.
parMap :: 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.
parFlatMap :: Strategy [b] -> (a -> [b]) -> [a] -> [b]
-- | Zips together two lists using a function, and evaluates the result
-- list in parallel.
parZipWith :: Strategy c -> (a -> b -> c) -> [a] -> [b] -> [c]
-- | Sequentially applies a strategy to each element of a list.
seqList :: Strategy a -> Strategy [a]
-- | Sequentially applies a strategy to the first n elements of a list.
seqListN :: Integral a => a -> 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.
seqListNth :: Int -> Strategy b -> Strategy [b]
-- | 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.
parBuffer :: Int -> Strategy a -> [a] -> [a]
-- | Apply a strategy to all elements of an array sequentially.
seqArr :: Ix b => Strategy a -> Strategy (Array b a)
-- | Apply a strategy to all elements of an array in parallel.
parArr :: Ix b => Strategy a -> Strategy (Array b a)
-- | 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.
sPar :: 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.
sSeq :: a -> Strategy b
data Assoc a b
(:=) :: a -> b -> Assoc a b
fstPairFstList :: NFData a => Strategy [(a, b)]
force :: NFData a => a -> a
sforce :: NFData a => a -> b -> b
instance (NFData a, NFData b) => NFData (Assoc a b)
instance (Ix a, NFData a, NFData b) => NFData (Array a b)
instance NFData a => NFData [a]
instance NFData IntSet
instance NFData a => NFData (IntMap a)
instance NFData a => NFData (Tree a)
instance NFData a => NFData (Set a)
instance (NFData k, NFData a) => NFData (Map k a)
instance (NFData a, NFData b) => NFData (Either a b)
instance NFData a => NFData (Maybe a)
instance NFData ()
instance NFData Bool
instance NFData Char
instance (RealFloat a, NFData a) => NFData (Complex a)
instance (Integral a, NFData a) => NFData (Ratio a)
instance NFDataOrd Int
instance NFDataIntegral Int
instance NFData Word64
instance NFData Word32
instance NFData Word16
instance NFData Word8
instance NFData Int64
instance NFData Int32
instance NFData Int16
instance NFData Int8
instance NFData Double
instance NFData Float
instance NFData Integer
instance NFData Int
instance (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)
instance (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)
instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7)
instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6)
instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5)
instance (NFData a, NFData b, NFData c, NFData d) => NFData (a, b, c, d)
instance (NFData a, NFData b, NFData c) => NFData (a, b, c)
instance (NFData a, NFData b) => NFData (a, b)