I’m new to Haskell and I’d like to be able to time the runtime of a given function call or snippet of code.
In Clojure I can use ‘time’:
user=> (time
Lazy means Lazy. Time is only relevant when inside a monad like IO.
Time has NO meaning in the expression "4 + 4" - or in any other mathematical equation. The answer simply IS. The "answer" to any other pure computation is already predetermined the instant that the computation is specified.
Unfortunately, this is the "answer" to your question. An answer that, in fact, existed before you even posed your question. It existed in 1998 when the language was finally defined. The fact that it took me a year to write this doesn't matter ;-)
OK, enough of that nonsense!!!! (But if the above is too annoying, then just forget about Haskell.)
If the Criterion package is too much pain, just write a test case and use +RTS to test it.
If you want to be really cool, create your own monad - one that times the execution of your algorithm and hands the result back tupled with the algorithm's return value. Good luck. We're all counting on you!