The Par monad and schedules

The parallel package restricts us to expressing our computations as lazy data structures. Moreover, such computations must always be pure, so no parallel IO is possible. Sometimes this isn't feasible and we would like to express more control. Somewhat inherently, more control implies less expressiveness. This trade-off is made in the monad-par package.

The core interface in Control.Monad.Par consists of:

data Par a  -- instance Monad
runPar :: Par a → a
fork :: Par () → Par ()

The monad-par library defines its own context for computations, namely Par. The second important operation, next to executing the computation via runPar, is fork, which forks a computation so it happens in parallel.

Communication between computations ...

Get Haskell High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.