Add unsafeSTToIO :: ST s a -> IO a
authorSimon Marlow <simonmar@microsoft.com>
Wed, 15 Mar 2006 16:02:32 +0000 (16:02 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Wed, 15 Mar 2006 16:02:32 +0000 (16:02 +0000)
Implementation for Hugs is missing, but should be easy.  We need this
for the forthcoming nested data parallelism implementation.

Control/Monad/ST.hs
GHC/IOBase.lhs

index 0a40720..d736eb6 100644 (file)
@@ -27,7 +27,8 @@ module Control.Monad.ST
 
        -- * Unsafe operations
        unsafeInterleaveST,     -- :: ST s a -> ST s a
-       unsafeIOToST            -- :: IO a -> ST s a
+       unsafeIOToST,           -- :: IO a -> ST s a
+       unsafeSTToIO            -- :: ST s a -> IO a
       ) where
 
 import Prelude
@@ -55,7 +56,7 @@ unsafeInterleaveST =
 #ifdef __GLASGOW_HASKELL__
 import GHC.ST          ( ST, runST, fixST, unsafeInterleaveST )
 import GHC.Base                ( RealWorld )
-import GHC.IOBase      ( stToIO, unsafeIOToST )
+import GHC.IOBase      ( stToIO, unsafeIOToST, unsafeSTToIO )
 #endif
 
 instance MonadFix (ST s) where
index 112268e..78a334d 100644 (file)
@@ -20,7 +20,7 @@ module GHC.IOBase(
     unsafePerformIO, unsafeInterleaveIO,
   
        -- To and from from ST
-    stToIO, ioToST, unsafeIOToST,
+    stToIO, ioToST, unsafeIOToST, unsafeSTToIO,
 
        -- References
     IORef(..), newIORef, readIORef, writeIORef, 
@@ -155,6 +155,9 @@ ioToST (IO m) = (ST m)
 unsafeIOToST        :: IO a -> ST s a
 unsafeIOToST (IO io) = ST $ \ s -> (unsafeCoerce# io) s
 
+unsafeSTToIO :: ST s a -> IO a
+unsafeSTToIO (ST m) = IO (unsafeCoerce# m)
+
 -- ---------------------------------------------------------------------------
 -- Unsafe IO operations