diff options
author | sof <unknown> | 2002-06-13 23:26:56 +0000 |
---|---|---|
committer | sof <unknown> | 2002-06-13 23:26:56 +0000 |
commit | 326ca1a9fa9246b88747778b381627e333526414 (patch) | |
tree | 996d3052c15be2cd8667027a68e86c6a4e350c14 | |
parent | 37e6bacc405b16d543b398999c8cd4624a3deeee (diff) | |
download | haskell-326ca1a9fa9246b88747778b381627e333526414.tar.gz |
[project @ 2002-06-13 23:26:55 by sof]
Provide STRefs over both lazy and strict ST monads as,
Data.STRef.Lazy
Data.STRef.Strict
Data.STRef <-- the strict version.
i.e., mirror how the strict and lazy ST monads are
organised over in Control.Monad.ST
-rw-r--r-- | libraries/base/Data/STRef.hs | 2 | ||||
-rw-r--r-- | libraries/base/Data/STRef/Lazy.hs | 37 | ||||
-rw-r--r-- | libraries/base/Data/STRef/Strict.hs | 20 | ||||
-rw-r--r-- | libraries/base/Makefile | 3 |
4 files changed, 60 insertions, 2 deletions
diff --git a/libraries/base/Data/STRef.hs b/libraries/base/Data/STRef.hs index 81b135173f..336a61fbd3 100644 --- a/libraries/base/Data/STRef.hs +++ b/libraries/base/Data/STRef.hs @@ -8,7 +8,7 @@ -- Stability : experimental -- Portability : non-portable (requires non-portable module ST) -- --- Mutable references in the ST monad. +-- Mutable references in the (strict) ST monad. -- ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/STRef/Lazy.hs b/libraries/base/Data/STRef/Lazy.hs new file mode 100644 index 0000000000..daa48a0f49 --- /dev/null +++ b/libraries/base/Data/STRef/Lazy.hs @@ -0,0 +1,37 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Data.STRef.Lazy +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : non-portable (requires non-portable module ST) +-- +-- Mutable references in the lazy ST monad. +-- +----------------------------------------------------------------------------- +module Data.STRef.Lazy ( + -- * STRefs + ST.STRef, -- abstract, instance Eq + newSTRef, -- :: a -> ST s (STRef s a) + readSTRef, -- :: STRef s a -> ST s a + writeSTRef, -- :: STRef s a -> a -> ST s () + modifySTRef -- :: STRef s a -> (a -> a) -> ST s () + ) where + +import Control.Monad.ST.Lazy +import qualified Data.STRef as ST +import qualified Control.Monad.ST as ST + +newSTRef :: a -> ST s (ST.STRef s a) +readSTRef :: ST.STRef s a -> ST s a +writeSTRef :: ST.STRef s a -> a -> ST s () +modifySTRef :: ST.STRef s a -> (a -> a) -> ST s () + +newSTRef = strictToLazyST . ST.newSTRef +readSTRef = strictToLazyST . ST.readSTRef +writeSTRef r a = strictToLazyST (ST.writeSTRef r a) +modifySTRef r f = strictToLazyST (ST.modifySTRef r f) + + diff --git a/libraries/base/Data/STRef/Strict.hs b/libraries/base/Data/STRef/Strict.hs new file mode 100644 index 0000000000..ee432f4161 --- /dev/null +++ b/libraries/base/Data/STRef/Strict.hs @@ -0,0 +1,20 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Data.STRef.Strict +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : provisional +-- Portability : non-portable (requires universal quantification for runST) +-- +-- Mutable references in the (strict) ST monad (re-export of "Data.STRef") +-- +----------------------------------------------------------------------------- + +module Data.STRef.Strict ( + module Data.STRef + ) where + +import Prelude +import Data.STRef diff --git a/libraries/base/Makefile b/libraries/base/Makefile index fab55a2ef0..8c6aab27c3 100644 --- a/libraries/base/Makefile +++ b/libraries/base/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.31 2002/06/08 13:11:27 panne Exp $ +# $Id: Makefile,v 1.32 2002/06/13 23:26:55 sof Exp $ TOP=.. include $(TOP)/mk/boilerplate.mk @@ -15,6 +15,7 @@ ALL_DIRS = \ Control/Monad/ST \ Data \ Data/Array \ + Data/STRef \ Database \ Debug \ Debug/QuickCheck \ |