Remove old test outputs
[packages/base.git] / Data / STRef.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE CPP #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Data.STRef
7 -- Copyright : (c) The University of Glasgow 2001
8 -- License : BSD-style (see the file libraries/base/LICENSE)
9 --
10 -- Maintainer : libraries@haskell.org
11 -- Stability : experimental
12 -- Portability : non-portable (uses Control.Monad.ST)
13 --
14 -- Mutable references in the (strict) ST monad.
15 --
16 -----------------------------------------------------------------------------
17
18 module Data.STRef (
19 -- * STRefs
20 STRef, -- abstract, instance Eq
21 newSTRef, -- :: a -> ST s (STRef s a)
22 readSTRef, -- :: STRef s a -> ST s a
23 writeSTRef, -- :: STRef s a -> a -> ST s ()
24 modifySTRef -- :: STRef s a -> (a -> a) -> ST s ()
25 ) where
26
27 import Prelude
28
29 #ifdef __GLASGOW_HASKELL__
30 import GHC.ST
31 import GHC.STRef
32 #endif
33
34 #ifdef __HUGS__
35 import Hugs.ST
36 import Data.Typeable
37
38 #include "Typeable.h"
39 INSTANCE_TYPEABLE2(STRef,stRefTc,"STRef")
40 #endif
41
42 -- |Mutate the contents of an 'STRef'
43 modifySTRef :: STRef s a -> (a -> a) -> ST s ()
44 modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref
45