O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

There are two primitives--rpar, which immediately returns, and rseq, which forces the argument into weak headed normal form (WHNF. WHNF is related to lazy evaluation in Haskell, and usually points to a minimally evaluated thunk. In WHNF, only a part of the thunk is evaluated, whereas in normal form (NF), the whole thunk is evaluated (or reduced). Both rpar and rseq work as Strategies. We specify the work in terms of Strategies in an Eval monad. The runEval function takes the Eval monad and parallelizes the computation.

This recipe also shows how to profile the project, and look at the event log. This comes in very handy especially when dealing with concurrency.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required