Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module System.IO.Unsafe
- unsafeFixIO :: (a -> IO a) -> IO a
- unsafeDupablePerformIO :: IO a -> a
Documentation
module System.IO.Unsafe
unsafeFixIO :: (a -> IO a) -> IO a #
A slightly faster version of fixIO
that may not be
safe to use with multiple threads. The unsafety arises when used
like this:
unsafeFixIO $ \r -> do forkIO (print r) return (...)
In this case, the child thread will receive a NonTermination
exception instead of waiting for the value of r
to be computed.
Since: base-4.5.0.0
unsafeDupablePerformIO :: IO a -> a #
This version of unsafePerformIO
is more efficient
because it omits the check that the IO is only being performed by a
single thread. Hence, when you use unsafeDupablePerformIO
,
there is a possibility that the IO action may be performed multiple
times (on a multiprocessor), and you should therefore ensure that
it gives the same results each time. It may even happen that one
of the duplicated IO actions is only run partially, and then interrupted
in the middle without an exception being raised. Therefore, functions
like bracket
cannot be used safely within unsafeDupablePerformIO
.
Since: base-4.4.0.0