#endif
, unsafePtrEq
- , unsafeIOToST
- , stToIO
) where
#endif
\end{code}
-\begin{code}
-unsafeIOToST :: IO a -> ST s a
-#ifdef __HUGS__
-unsafeIOToST = primUnsafeCoerce
-#else
-unsafeIOToST (IO io) = ST $ \ s ->
- case ((unsafeCoerce# io) s) of
- (# new_s, a #) -> unsafeCoerce# (STret new_s a)
--- IOfail new_s e -> error ("I/O Error (unsafeIOToST): " ++ showsPrec 0 e "\n")
-#endif
-\end{code}
-
Not something you want to call normally, but useful
in the cases where you do want to flush stuff out of
the heap or make sure you've got room enough
thawSTArray, freezeSTArray, unsafeFreezeSTArray,
Ix,
+ ST.unsafeIOToST, ST.stToIO,
+
strictToLazyST, lazyToStrictST
) where
newSTRef = strictToLazyST . ST.newSTRef
readSTRef = strictToLazyST . ST.readSTRef
writeSTRef r a = strictToLazyST (ST.writeSTRef r a)
+
\end{code}
%*********************************************************
STRef,
newSTRef, readSTRef, writeSTRef,
+ unsafeIOToST, stToIO,
+
STArray,
newSTArray, readSTArray, writeSTArray, boundsSTArray,
thawSTArray, freezeSTArray, unsafeFreezeSTArray,
#else
import PrelArr
import PrelST
-import PrelBase ( Eq(..), Int, Bool, ($), ()(..) )
+import PrelBase ( Eq(..), Int, Bool, ($), ()(..), unsafeCoerce# )
+import PrelIOBase ( IO(..), stToIO )
#endif
import Monad
import Ix
#endif
\end{code}
+
+\begin{code}
+unsafeIOToST :: IO a -> ST s a
+#ifdef __HUGS__
+unsafeIOToST = primUnsafeCoerce
+#else
+unsafeIOToST (IO io) = ST $ \ s ->
+ case ((unsafeCoerce# io) s) of
+ (# new_s, a #) -> unsafeCoerce# (STret new_s a)
+-- IOfail new_s e -> error ("I/O Error (unsafeIOToST): " ++ showsPrec 0 e "\n")
+#endif
+\end{code}