
"Sean" == Sean Lee
writes:
Sean> Hi Colin The following code probably would do what I wanted Sean> to do. Sean> play_move :: IORef Game_state -> IO () play_move Sean> game_state_ior = do (_, state, _) <- readIORef Sean> game_state_ior putStr "Playing AI: " start_time <- Sean> getCurrentTime let move = recommended_move state end_time <- Sean> move `seq` (modifyIORef game_state_ior $! Sean> update_interactive_from_move move) `seq` getCurrentTime Sean> putStrLn $ show $ (diffUTCTime end_time start_time) Sean> Due to the non-strictness of Haskell, the evaluation of the Sean> expressions between start_time and end_time is deferred Sean> until there is a need. By using `seq` and ($!), the Sean> strictness can be forced. It certainly causes a time delay, and a non-zero time is printed, but the state doesn't get modified correctly now. ?? I will ponder Daniel's suggestion. -- Colin Adams Preston Lancashire