2 % (c) The AQUA Project, Glasgow University, 1994-1996
5 \section[PrelUnsafe]{Module @PrelUnsafe@}
7 These functions have their own module because we definitely don't want
8 them to be inlined. The reason is that we may end up turning an action
9 into a constant when it is not:
14 foo = unsafePerformIO getNextValue
18 If unsafePerformIO is inlined here, the application of getNextValue to the realWorld#
19 token might be floated out, leaving us with
21 foo' = getNextValue realWorld#
26 which is not what we want.
29 {-# OPTIONS -fno-implicit-prelude #-}
42 import {-# SOURCE #-} PrelErr ( error )
45 %*********************************************************
47 \subsection{Unsafe @IO@ operations}
49 %*********************************************************
52 unsafePerformIO :: IO a -> a
53 unsafePerformIO (IO m)
54 = case m realWorld# of
56 IOfail _ e -> error ("unsafePerformIO: I/O error: " ++ show e ++ "\n")
58 unsafeInterleaveIO :: IO a -> IO a
59 unsafeInterleaveIO (IO m) = IO ( \ s ->
64 IOfail _ e -> error ("unsafeInterleaveIO: I/O error: " ++ show e ++ "\n")
70 trace :: String -> a -> a
73 ((_ccall_ PreTraceHook sTDERR{-msg-}):: IO ()) >>
74 fputs sTDERR string >>
75 ((_ccall_ PostTraceHook sTDERR{-msg-}):: IO ()) >>
78 sTDERR = (``stderr'' :: Addr)