1 -----------------------------------------------------------------------------
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable (requires non-portable module ST)
11 -- Mutable references in the (strict) ST monad.
13 -----------------------------------------------------------------------------
17 STRef, -- abstract, instance Eq
18 newSTRef, -- :: a -> ST s (STRef s a)
19 readSTRef, -- :: STRef s a -> ST s a
20 writeSTRef, -- :: STRef s a -> a -> ST s ()
21 modifySTRef -- :: STRef s a -> (a -> a) -> ST s ()
26 #ifdef __GLASGOW_HASKELL__
36 INSTANCE_TYPEABLE2(STRef,stRefTc,"STRef")
39 -- |Mutate the contents of an 'STRef'
40 modifySTRef :: STRef s a -> (a -> a) -> ST s ()
41 modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref