Faster filterF, filterNotByte
[packages/old-time.git] / Data / STRef.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : Data.STRef
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
6 --
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable (uses Control.Monad.ST)
10 --
11 -- Mutable references in the (strict) ST monad.
12 --
13 -----------------------------------------------------------------------------
14
15 module Data.STRef (
16 -- * STRefs
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 ()
22 ) where
23
24 import Prelude
25
26 #ifdef __GLASGOW_HASKELL__
27 import GHC.ST
28 import GHC.STRef
29 #endif
30
31 #ifdef __HUGS__
32 import Hugs.ST
33 import Data.Typeable
34
35 #include "Typeable.h"
36 INSTANCE_TYPEABLE2(STRef,stRefTc,"STRef")
37 #endif
38
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