Hi Mihai,<br>maybe the term &quot;thread&quot; in my mail is not correct.<br>What I mean is that a value gets stored by f and discovered by g.<br><br> <i>f,g :: IO ()<br>f = withFile &quot;toto&quot; WriteMode (flip hPutStr &quot;42&quot;)<br>

g = withFile &quot;toto&quot; ReadMode hGetLine &gt;&gt;= (\s -&gt; putStrLn $ &quot;Answer:&quot; ++ s)<br>
main = f &gt;&gt; g</i><br><br>Is it possible to do the same without files (the types must remain IO())?<br><br><br><div class="gmail_quote">On Wed, Aug 29, 2012 at 11:04 AM, Mihai Maruseac <span dir="ltr">&lt;<a href="mailto:mihai.maruseac@gmail.com" target="_blank">mihai.maruseac@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Wed, Aug 29, 2012 at 10:58 AM, Corentin Dupont<br>
&lt;<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>&gt; wrote:<br>
&gt; Hi all,<br>
&gt; there is something very basic that it seems escaped me.<br>
&gt; For example with the following program f and g have type IO () and I can<br>
&gt; thread a value between the two using a file.<br>
&gt; Can I do the exact same (not changing the types of f and g) without a file?<br>
&gt;<br>
&gt; f,g :: IO ()<br>
&gt; f = withFile &quot;toto&quot; WriteMode (flip hPutStr &quot;toto&quot;)<br>
&gt; g = withFile &quot;toto&quot; ReadMode hGetLine &gt;&gt;= putStrLn<br>
&gt; main = f &gt;&gt; g<br>
<br>
</div></div>Of course:<br>
<br>
f,g :: IO ()<br>
f = putStr &quot;Answer: &quot;<br>
g = print 42<br>
<br>
Main&gt; f &gt;&gt; g<br>
Answer: 42<br>
<br>
The () is threaded by &gt;&gt;, not the file content<br>
<span><font color="#888888"><br>
--<br>
MM<br>
</font></span></blockquote></div><br>