[project @ 2003-05-12 08:48:09 by ross]
authorross <unknown>
Mon, 12 May 2003 08:48:09 +0000 (08:48 +0000)
committerross <unknown>
Mon, 12 May 2003 08:48:09 +0000 (08:48 +0000)
some re-arrangement for the benefit of Hugs.

Control/Monad/ST.hs
Control/Monad/ST/Lazy.hs
Data/STRef.hs
Data/STRef/Lazy.hs
GHC/STRef.lhs

index 7341cef..008dafc 100644 (file)
@@ -37,6 +37,14 @@ import Data.Dynamic
 
 #ifdef __HUGS__
 import Hugs.ST
+import qualified Hugs.LazyST as LazyST
+
+fixST :: (a -> ST s a) -> ST s a
+fixST f = LazyST.lazyToStrictST (LazyST.fixST (LazyST.strictToLazyST . f))
+
+unsafeInterleaveST :: ST s a -> ST s a
+unsafeInterleaveST =
+    LazyST.lazyToStrictST . LazyST.unsafeInterleaveST . LazyST.strictToLazyST
 #endif
 
 #ifdef __GLASGOW_HASKELL__
index 60ff1be..413659e 100644 (file)
@@ -28,18 +28,18 @@ module Control.Monad.ST.Lazy (
        RealWorld,
        stToIO,
 
-#ifndef __HUGS__
        -- * Converting between strict and lazy 'ST'
        strictToLazyST, lazyToStrictST
-#endif
     ) where
 
 import Prelude
 
 import Control.Monad.Fix
 
-#ifdef __GLASGOW_HASKELL__
+import Control.Monad.ST (RealWorld)
 import qualified Control.Monad.ST as ST
+
+#ifdef __GLASGOW_HASKELL__
 import qualified GHC.ST
 import GHC.Base
 import Control.Monad
@@ -118,10 +118,10 @@ lazyToStrictST (ST m) = GHC.ST.ST $ \s ->
 
 unsafeInterleaveST :: ST s a -> ST s a
 unsafeInterleaveST = strictToLazyST . ST.unsafeInterleaveST . lazyToStrictST
+#endif
 
 unsafeIOToST :: IO a -> ST s a
 unsafeIOToST = strictToLazyST . ST.unsafeIOToST
 
 stToIO :: ST RealWorld a -> IO a
 stToIO = ST.stToIO . lazyToStrictST
-#endif
index e25e8b5..a48e29a 100644 (file)
@@ -24,6 +24,7 @@ module Data.STRef (
 import Prelude
 
 #ifdef __GLASGOW_HASKELL__
+import GHC.ST
 import GHC.STRef
 #endif
 
@@ -35,3 +36,7 @@ import Data.Dynamic
 
 #include "Dynamic.h"
 INSTANCE_TYPEABLE2(STRef,stRefTc,"STRef")
+
+-- |Mutate the contents of an 'STRef'
+modifySTRef :: STRef s a -> (a -> a) -> ST s ()
+modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref
index b05fb83..faf7de5 100644 (file)
@@ -21,9 +21,6 @@ module Data.STRef.Lazy (
  ) where
 
 import Control.Monad.ST.Lazy
-#ifdef __HUGS__
-import Hugs.LazyST as ST
-#else
 import qualified Data.STRef as ST
 import qualified Control.Monad.ST as ST
 
@@ -36,5 +33,3 @@ newSTRef   = strictToLazyST . ST.newSTRef
 readSTRef  = strictToLazyST . ST.readSTRef
 writeSTRef r a = strictToLazyST (ST.writeSTRef r a)
 modifySTRef r f = strictToLazyST (ST.modifySTRef r f)
-
-#endif  /* __HUGS__ */
index 5eecb85..ed56bc9 100644 (file)
@@ -39,10 +39,6 @@ writeSTRef (STRef var#) val = ST $ \s1# ->
     case writeMutVar# var# val s1#      of { s2# ->
     (# s2#, () #) }
 
--- |Mutate the contents of an 'STRef'
-modifySTRef :: STRef s a -> (a -> a) -> ST s ()
-modifySTRef ref f = readSTRef ref >>= writeSTRef ref . f
-
 -- Just pointer equality on mutable references:
 instance Eq (STRef s a) where
     STRef v1# == STRef v2# = sameMutVar# v1# v2#