<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Am Do., 29. Nov. 2018 um 19:43 Uhr schrieb Johannes Waldmann <<a href="mailto:johannes.waldmann@htwk-leipzig.de">johannes.waldmann@htwk-leipzig.de</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am surprised by the behaviour of the program below<br>
(the interesting property is whether it will output "foo").<br>
<br>
Behaviours (plural) actually: it seems to depend<br>
on optimisation level, on omit-yields,<br>
and on very small changes in the source code: [...]<br></blockquote><div><br></div><div>IMHO there is nothing very surprising here: You have 2 threads with no synchronization between them whatsoever, so you get what you deserve: Undefined behavior. :-) This is the behavior you get in basically all programming languages/execution environments I know of, *unless* they make a very strong guarantee about their scheduling behavior (whichis very rare, for good reasons). Do we have such a guarantee somewhere in the GHC/base documentation? I don't think so, but if we had, I would be interested to see a reference to that.</div><div><br></div><div>Cheers,</div><div>   S.</div></div></div>