Movatterモバイル変換
[0]ホーム
{-# LANGUAGE Unsafe #-}{-# LANGUAGE NoImplicitPrelude, MagicHash #-}{-# OPTIONS_GHC -funbox-strict-fields #-}{-# OPTIONS_HADDOCK hide #-}------------------------------------------------------------------------------- |-- Module : GHC.IORef-- Copyright : (c) The University of Glasgow 2008-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC Extensions)---- The IORef type-------------------------------------------------------------------------------moduleGHC.IORef(IORef(..),newIORef,readIORef,writeIORef,atomicModifyIORef)whereimportGHC.BaseimportGHC.STRefimportGHC.IO-- ----------------------------------------------------------------------------- IORefs-- |A mutable variable in the 'IO' monadnewtypeIORefa=IORef(STRefRealWorlda)derivingEq-- ^ @since 4.2.0.0-- ^ Pointer equality.---- @since 4.1.0.0-- |Build a new 'IORef'newIORef::a->IO(IORefa)newIORefv=stToIO(newSTRefv)>>=\var->return(IORefvar)-- |Read the value of an 'IORef'readIORef::IORefa->IOareadIORef(IORefvar)=stToIO(readSTRefvar)-- |Write a new value into an 'IORef'writeIORef::IORefa->a->IO()writeIORef(IORefvar)v=stToIO(writeSTRefvarv)atomicModifyIORef::IORefa->(a->(a,b))->IObatomicModifyIORef(IORef(STRefr#))f=IO$\s->atomicModifyMutVar#r#fs
[8]ページ先頭