parallel-3.2.2.0: Parallel programming library
Copyright (c) The University of Glasgow 2001-2009
License BSD-style (see the file libraries/base/LICENSE)
Maintainer libraries@haskell.org
Stability experimental
Portability portable
Safe Haskell Safe-Inferred
Language Haskell2010

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 -> () 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 :: 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 :: 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.