Skip to content
Snippets Groups Projects
Commit d52a9a6b authored by sof's avatar sof
Browse files

[project @ 1997-07-05 03:16:22 by sof]

new module
parent d6b3eb2f
No related merge requests found
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
%
\section[UnsafeST]{Unsafe ST operations}
VERY IMPORTANT! This module must be compiled without "-O". If you
compile it with "-O" then the inlinings of the unsafe ST operators are exposed.
It turns out that exposing these inlininings can lead to unsound transformations,
such as generating a MutVar only once rather than once each call to unsafePerformIO.
\begin{code}
{-# OPTIONS -fno-implicit-prelude -Onot #-}
\end{code}
\begin{code}
module UnsafeST(
unsafeInterleaveST,
unsafePerformPrimIO,
unsafeInterleavePrimIO
) where
import STBase
import PrelBase
import GHC
unsafeInterleaveST :: ST s a -> ST s a
unsafeInterleaveST (ST m) = ST $ \ s ->
let
(r, new_s) = m s
in
(r, s)
unsafePerformPrimIO :: PrimIO a -> a
-- We give a fresh definition here. There are no
-- magical universal types kicking around.
unsafePerformPrimIO (ST m)
= case m (S# realWorld#) of
(r,_) -> r
unsafeInterleavePrimIO :: PrimIO a -> PrimIO a
unsafeInterleavePrimIO = unsafeInterleaveST
\end{code}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment