On Wed, Sep 19, 2012 at 8:00 PM,  <sdiy...@sjtu.edu.cn> wrote:
> So how do I force IO actions whose results are discarded (including IO ()) to 
> be strict?

In your particular case it looks like you want
Data.IORef.modifyIORef'. If your version of GHC doesn't include it you
can write it like so:

-- |Strict version of 'modifyIORef'
modifyIORef' :: IORef a -> (a -> a) -> IO ()
modifyIORef' ref f = do
    x <- readIORef ref
    let x' = f x
    x' `seq` writeIORef ref x'

-- Johan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to