[Haskell-beginners] force strict expression evaluation

Felipe Almeida Lessa felipe.lessa at gmail.com
Tue Aug 2 18:11:15 CEST 2011


On Tue, Aug 2, 2011 at 12:58 PM, Ovidiu Deac <ovidiudeac at gmail.com> wrote:
> I'm trying to do some performance evaluation and I'm stuck with the
> fact that Haskell's lazy evaluation - which make my sort extremely
> fast :)

You'll probably want to take a look at criterion [1].

[1] http://hackage.haskell.org/package/criterion

> I read this page:
> http://www.haskell.org/haskellwiki/Performance/Strictness but I didn't
> get it so I'm asking here: How do I make the function 'measure' to
> actually force the evaluation of (f p)?

One possible solution is:

  import Control.Exception (evaluate)
  import Control.DeepSeq (rnf)

  ... = do
    ...
    evaluate (rnf sorted)
    ...

HTH,

-- 
Felipe.



More information about the Beginners mailing list