Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (14 sloc) 383 Bytes
module IORefRef
( Ref, new, read, write, link )
where
import Prelude hiding (read)
import Data.IORef
newtype Ref a = Ref (IORef a)
new :: a -> IO (Ref a)
new = fmap Ref . newIORef
read :: Ref a -> IO a
read (Ref ioref) = readIORef ioref
write :: Ref a -> a -> IO ()
write (Ref ioref) = writeIORef ioref
link :: Ref a -> Ref a -> IO ()
link old new = write old =<< read new