parallel-3.2.2.0: Parallel programming library

Control.Seq

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 -> () #

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 #

Evaluate a value using the given strategy.

withStrategy :: Strategy a -> a -> a #

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

# Basic sequential strategies

r0 :: Strategy a #

r0 performs *no* evaluation.

rseq evaluates its argument to weak head normal form.

rdeepseq :: NFData a => Strategy a #

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

# Sequential strategies for lists

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

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] #

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

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

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) #

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

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

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

seqArray :: Strategy a -> Strategy (Array i a) #

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

seqArrayBounds :: Strategy i -> Strategy (Array i a) #

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.

seqTuple2 :: Strategy a -> Strategy b -> Strategy (a, b) #

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

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

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

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

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

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) #

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) #