From 4f72c9cd9f46ff4f42ba1c48f7847190c41542c4 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 15 Mar 2006 16:02:32 +0000 Subject: [PATCH] Add unsafeSTToIO :: ST s a -> IO a Implementation for Hugs is missing, but should be easy. We need this for the forthcoming nested data parallelism implementation. --- Control/Monad/ST.hs | 5 +++-- GHC/IOBase.lhs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Control/Monad/ST.hs b/Control/Monad/ST.hs index 0a40720..d736eb6 100644 --- a/Control/Monad/ST.hs +++ b/Control/Monad/ST.hs @@ -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 diff --git a/GHC/IOBase.lhs b/GHC/IOBase.lhs index 112268e..78a334d 100644 --- a/GHC/IOBase.lhs +++ b/GHC/IOBase.lhs @@ -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 -- 1.7.10.4