Par and seq
Revision as of 10:36, 30 September 2008 by Lemming
have much in common.
They have the same signature and thus the same use patterns.The function
let you start a computation in parallel and
forces a computation to actually take place (avoiding lazy evaluation).
You could also define a function
par :: a -> b -> b seq :: a -> b -> b
which computes the arguments of a two-argument function
in parallel before feeding them to
par2 :: (a -> b -> c) -> (a -> b -> c) par2 f x y = x `par` y `par` f x y
is also universal, because you can define
in terms of
You can see, that
par = par2 (\ _x y -> y)
is the more basic combinator, because it scales to any number of arguments.
- Haskell-Cafe: 'par' - why has it the type a -> b -> b ?