Eval package:parallel

Eval is a Monad that makes it easier to define parallel strategies. It is a strict identity monad: that is, in
m >>= f
m is evaluated before the result is passed to f.
instance Monad Eval where
return  = Done
m >>= k = case m of
Done x -> k x
If you wanted to construct a Strategy for a pair that sparked the first component in parallel and then evaluated the second component, you could write
myStrat :: Strategy (a,b)
myStrat (a,b) = do { a' <- rpar a; b' <- rseq b; return (a',b') }
Alternatively, you could write this more compactly using the Applicative style as
myStrat (a,b) = (,) <$> rpar a <*> rseq b
evalBuffer is a rolling buffer strategy combinator for (lazy) lists. evalBuffer is not as compositional as the type suggests. In fact, it evaluates list elements at least to weak head normal form, disregarding a strategy argument r0.
evalBuffer n r0 == evalBuffer n rseq
Evaluate each element of a list according to the given strategy. Equivalent to evalTraversable at the list type.
Evaluate the first n elements of a list according to the given strategy.
Evaluate the nth element of a list (if there is such) according to the given strategy. This nth is 0-based. For example, [1, 2, 3, 4, 5] using evalListNth 4 rseq will eval 5, not 4. The spine of the list up to the nth element is evaluated as a side effect.
evaListSplitAt n stratPref stratSuff evaluates the prefix (of length n) of a list according to stratPref and its the suffix according to stratSuff.
Inject a sequential strategy (ie. coerce a sequential strategy to a general strategy). Thanks to evalSeq, the type Control.Seq.Strategy a is a subtype of Strategy a.
Evaluate the elements of a traversable data structure according to the given strategy.
parEval sparks the computation of its argument for evaluation in parallel. Unlike rpar . runEval, parEval
  • does not exit the Eval monad
  • does not have a built-in rseq, so for example parEval (r0 x) behaves as you might expect (it creates a spark that does no evaluation).
It is related to rparWith by the following equality:
parEval . strat = rparWith strat
Pull the result out of the monad.
Run the evaluation in the IO monad. This allows sequencing of evaluations relative to IO actions.
Deprecated: renamed to runEval