<div dir="ltr">This code works, so I don't think that's the case either:<div><br></div><div><div> import Control.Concurrent.STM</div><div> import Data.IORef</div><div> import System.IO.Unsafe</div><div> </div><div> main :: IO ()</div><div> main = do</div><div> ref <- newIORef (6 :: Int)</div><div> i <- atomically $ do</div><div> var <- newTVar (unsafePerformIO (readIORef ref))</div><div> readTVar var</div><div> print i</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 12, 2017 at 11:28 AM, Henning Thielemann <span dir="ltr"><<a href="mailto:lemming@henning-thielemann.de" target="_blank">lemming@henning-thielemann.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On Sun, 12 Nov 2017, Andrew Martin wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In the stm package, the docs for atomically read:<br>
<br>
> You cannot use 'atomically' inside an 'unsafePerformIO' or > 'unsafeInterleaveIO'. Any attempt to do so will result in a runtime > error. (Reason: allowing this would effectively allow a transaction > inside a transaction, depending on exactly when the thunk is > evaluated.)<br>
</blockquote>
<br></span>
I always thought that it would be the other way round, i.e. that you cannot call 'unsafePerformIO' inside an 'atomically'. Maybe I mixed something up.</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">-Andrew Thaddeus Martin</div>
</div>