parallel-3.2.0.4: Parallel programming library

Copyright(c) The University of Glasgow 2001-2009
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Seq

Contents

Description

Sequential strategies provide ways to compositionally specify the degree of evaluation of a data type between the extremes of no evaluation and full evaluation. Sequential strategies may be viewed as complimentary to the parallel ones (see module Control.Parallel.Strategies).

Synopsis

The sequential strategy type

type Strategy a = a -> () Source

The type Strategy a is a -> (). Thus, a strategy is a function whose sole purpose it is to evaluate its argument (either in full or in part).

Application of sequential strategies

using :: a -> Strategy a -> a infixl 0 Source

Evaluate a value using the given strategy.

withStrategy :: Strategy a -> a -> a Source

Evaluate a value using the given strategy. This is simply using with arguments reversed.

Basic sequential strategies

r0 :: Strategy a Source

r0 performs *no* evaluation.

rseq :: Strategy a Source

rseq evaluates its argument to weak head normal form.

rdeepseq :: NFData a => Strategy a Source

rdeepseq fully evaluates its argument. Relies on class NFData from module Control.DeepSeq.

Sequential strategies for lists

seqList :: Strategy a -> Strategy [a] Source

Evaluate each element of a list according to the given strategy. This function is a specialisation of seqFoldable to lists.

seqListN :: Int -> Strategy a -> Strategy [a] Source

Evaluate the first n elements of a list according to the given strategy.

seqListNth :: Int -> Strategy a -> Strategy [a] Source

Evaluate the nth element of a list (if there is such) according to the given strategy. The spine of the list up to the nth element is evaluated as a side effect.

Sequential strategies for foldable data types

seqFoldable :: Foldable t => Strategy a -> Strategy (t a) Source

Evaluate the elements of a foldable data structure according to the given strategy.

seqMap :: Strategy k -> Strategy v -> Strategy (Map k v) Source

Evaluate the keys and values of a map according to the given strategies.

seqArray :: Ix i => Strategy a -> Strategy (Array i a) Source

Evaluate the elements of an array according to the given strategy. Evaluation of the array bounds may be triggered as a side effect.

seqArrayBounds :: Ix i => Strategy i -> Strategy (Array i a) Source

Evaluate the bounds of an array according to the given strategy.

Sequential strategies for tuples

Evaluate the components of a tuple according to the given strategies. No guarantee is given as to the order of evaluation.

seqTuple3 :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c) Source

seqTuple4 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy (a, b, c, d) Source

seqTuple5 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy (a, b, c, d, e) Source

seqTuple6 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy (a, b, c, d, e, f) Source

seqTuple7 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy (a, b, c, d, e, f, g) Source

seqTuple8 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy (a, b, c, d, e, f, g, h) Source

seqTuple9 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy i -> Strategy (a, b, c, d, e, f, g, h, i) Source