From: simonmar Date: Fri, 10 May 2002 14:51:14 +0000 (+0000) Subject: [project @ 2002-05-10 14:51:14 by simonmar] X-Git-Tag: nhc98-1-18-release~1024 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c7a018c221ea569fe00ae6abeec5768f7072aeef;p=ghc-base.git [project @ 2002-05-10 14:51:14 by simonmar] Add some documentation for IORef --- diff --git a/GHC/IOBase.lhs b/GHC/IOBase.lhs index b2ec6e6..e82b2bc 100644 --- a/GHC/IOBase.lhs +++ b/GHC/IOBase.lhs @@ -317,14 +317,18 @@ data BufferMode -- --------------------------------------------------------------------------- -- IORefs +-- |A mutable variable in the 'IO' monad newtype IORef a = IORef (STRef RealWorld a) deriving Eq +-- |Build a new 'IORef' newIORef :: a -> IO (IORef a) newIORef v = stToIO (newSTRef v) >>= \ var -> return (IORef var) +-- |Read the value of an 'IORef' readIORef :: IORef a -> IO a readIORef (IORef var) = stToIO (readSTRef var) +-- |Write a new value into an 'IORef' writeIORef :: IORef a -> a -> IO () writeIORef (IORef var) v = stToIO (writeSTRef var v)