
Go backward to Strategies Controlling Evaluation Degree
Go up to Strategies Separate Algorithm from Dynamic Behaviour
Go forward to Data-oriented Parallelism
Combining Strategies
Because evaluation strategies are just normal higher-order functions,
they can be combined using the full power of the language, e.g.
passed as parameters or composed using the function composition
operator. Elements of a strategy are combined by sequential or
parallel composition (seq or par). Many useful
strategies are higher-order, for example, seqList below is
a strategy that sequentially applies a strategy to every element of a
list. The strategy seqList r0 evaluates just the spine of
a list, and seqList rwhnf evaluates every element of a
list to WHNF. There are analogous functions for every datatype, indeed
in later versions of Haskell (1.3 and later [Peterson et al., 1996])
constructor classes can be defined that work on arbitrary
datatypes. The strategic examples in this paper are presented in
Haskell 1.2 for pragmatic reasons: they are extracted from programs
run on our efficient parallel implementation of
Haskell 1.2 [Trinder et al., 1996].
seqList :: Strategy a -> Strategy [a]
seqList strat [] = ()
seqList strat (x:xs) = strat x `seq` (seqList strat xs)
{trinder,hwloidl,simonpj}@dcs.gla.ac.uk, kh@dcs.st-and.ac.uk
