<p dir="ltr">Hey Yotam,</p>
<p dir="ltr">Pattern matching clauses evaluate from left to right. You can get the behavour you're after by swapping the arguments in the tuple:</p>
<p dir="ltr">case (stop, infi) of<br>
(Just _, Nothing) -> 1<br>
(_, _) -> 2</p>
<p dir="ltr">Evaluates to 2</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, 20 Jun. 2017, 7:29 pm Yotam Ohad, <<a href="mailto:yotam2206@gmail.com">yotam2206@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">Hi,</div><div dir="ltr">After reading "<a href="https://pdfs.semanticscholar.org/fb7a/879d639641341e025197b40afad9e21f0ce5.pdf" target="_blank">Push-Pull Functional Reactive Programming</a>" I had an idea about deciding which, of two events, comes first. Instead of using forkIO, I tried something like the following:</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">infi :: Maybe Int</div><div dir="ltr">infi = infi</div><div dir="ltr"><br></div><div dir="ltr">stop :: Maybe Int</div><div dir="ltr">stop = Nothing</div><div dir="ltr"><br></div><div dir="ltr">test :: Int</div><div dir="ltr">test = case (infi, stop) of</div><div dir="ltr"> (Nothing, Just _) -> 1</div><div dir="ltr"> (_, _) -> 2</div><div dir="ltr"><br></div><div>Here, infi is an action that never ends, and stop a function that ends immediately. I thought that the compiler would see that stop evaluates immediately to Nothing and thus will return 2, but it tries to evaluate infi and get stuck.</div><div><br></div><div>I think it happens because I am using a tuple to hold both values (but not really sure about it). Do you know a way to make this arrangement work?</div><div><br></div><div>Yotam</div></div></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>