[Haskell-beginners] How to display a time difference?

Yitzchak Gale gale at sefer.org
Wed Mar 18 06:21:16 EDT 2009

Colin Paul Adams wrote:
> The code of the following routine is intended to indicate how long it
> takes for the computer to make a move. However the time is printed (as
> very close to zero) long before the move is made.

You are writing a thunk to the IORef. It only gets computed
later on when you read the value.

Try using:

> readIORef game_state_ior >>=
>    evaluate . update_interactive_from_move move >>=
>    writeIORef game_state_ior

evaluate is in Control.Exception.


More information about the Beginners mailing list