[Haskell-cafe] semantics of concurrent program depends on -O level, -f[no-]omit-yields

Ian Denhardt ian at zenhack.net
Fri Nov 30 18:33:22 UTC 2018


Quoting Johannes Waldmann (2018-11-30 05:50:03)

> Given that, it now feels strange that the following *does* work:
>
> main = do
>   forkIO $ do threadDelay 1000000 ; putStrLn "foo"
>   forever $ putStr ""
>
> I am seeing the "foo" output. I expect the last line
> to be non-allocating. But it does still yield? Why?

putStr has to acquire a lock on stdout, so that's probably enough to
allow the scheduler to run.


More information about the Haskell-Cafe mailing list