OK -- thanks everybody for your enlightening responses.<div><br></div><div>Regards,</div><div><br></div><div>Matt.<br><br><div class="gmail_quote">On Thu, Jun 7, 2012 at 9:40 PM, Henry Lockyer <span dir="ltr">&lt;<a href="mailto:henry.lockyer@ntlworld.com" target="_blank">henry.lockyer@ntlworld.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">in other words, in your version &quot;What&#39;s your name?&quot; *has* been put in the IO output buffer but this has not been flushed<br>

to the terminal yet. You then input your name (without having seen the prompt you were expecting (yet)) and then<br>
the newline of your subsequent putStrLn flushes both bits of output at the same time.<br>
<div class="HOEnZb"><div class="h5"><br>
On 7 Jun 2012, at 12:32, Henry Lockyer wrote:<br>
<br>
&gt; A very quick reply and without reading carefully considering what may be different in GHCI  (!),<br>
&gt; but the output buffer flushes (at least on my system) with newline  (if you don;t flush it &#39;manually&#39;).<br>
&gt; I suspect if you use putStrLn for &#39;what&#39;s your name&#39; you may get something more like what you want.<br>
&gt;<br>
&gt;<br>
&gt; On 7 Jun 2012, at 12:22, Matthew Moppett wrote:<br>
&gt;<br>
&gt;&gt; I have a very simple Haskell file (HelloWorld.hs) that reads like this:<br>
&gt;&gt;<br>
&gt;&gt; main = do<br>
&gt;&gt;    putStr &quot;What&#39;s your name? &quot;<br>
&gt;&gt;    n &lt;- getLine<br>
&gt;&gt;    putStrLn $ &quot;Pleased to meet you, &quot; ++ n<br>
&gt;&gt;<br>
&gt;&gt; When I load it into ghci, I get the following result, as expected:<br>
&gt;&gt;<br>
&gt;&gt; [1 of 1] Compiling Main             ( HelloWorld.hs, interpreted )<br>
&gt;&gt; Ok, modules loaded: Main.<br>
&gt;&gt; *Main&gt; main<br>
&gt;&gt; What&#39;s your name? Matt<br>
&gt;&gt; Pleased to meet you, Matt<br>
&gt;&gt; *Main&gt;<br>
&gt;&gt;<br>
&gt;&gt; However, when I compile the same file using ghc and run it in a terminal, I get a very different result:<br>
&gt;&gt;<br>
&gt;&gt; matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs<br>
&gt;&gt; [1 of 1] Compiling Main             ( HelloWorld.hs, HelloWorld.o )<br>
&gt;&gt; Linking HelloWorld ...<br>
&gt;&gt; matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld<br>
&gt;&gt; Matt<br>
&gt;&gt; What&#39;s your name? Pleased to meet you, Matt<br>
&gt;&gt; matt@matt-Lenovo-G575:~/Haskell$<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -- in other words, the getLine action is being run before the putStr action, for some strange reason.<br>
&gt;&gt;<br>
&gt;&gt; Is this a bug? Can anyone enlighten me as to what might be going on?<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt;<br>
&gt;&gt; Matt.<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Beginners mailing list<br>
&gt;&gt; <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Beginners mailing list<br>
&gt; <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
</div></div></blockquote></div><br></div>