Portability | portable |
---|---|

Stability | experimental |

Maintainer | libraries@haskell.org |

Safe Haskell | Safe-Infered |

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

- type Strategy a = a -> ()
- using :: a -> Strategy a -> a
- withStrategy :: Strategy a -> a -> a
- r0 :: Strategy a
- rseq :: Strategy a
- rdeepseq :: NFData a => Strategy a
- seqList :: Strategy a -> Strategy [a]
- seqListN :: Int -> Strategy a -> Strategy [a]
- seqListNth :: Int -> Strategy a -> Strategy [a]
- seqFoldable :: Foldable t => Strategy a -> Strategy (t a)
- seqMap :: Strategy k -> Strategy v -> Strategy (Map k v)
- seqArray :: Ix i => Strategy a -> Strategy (Array i a)
- seqArrayBounds :: Ix i => Strategy i -> Strategy (Array i a)
- 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)

# The sequential strategy type

type Strategy a = a -> ()Source

The type

is `Strategy`

a`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

withStrategy :: Strategy a -> a -> aSource

Evaluate a value using the given strategy.
This is simply `using`

with arguments reversed.

# Basic sequential strategies

rdeepseq :: NFData a => Strategy aSource

`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.

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