<div dir="ltr"><div><div>Thanks.<br><br>I can see it working but I don&#39;t undestand why does untilexit actually stop the processing. Can you explain that?<br><br></div>Also how could I display a prompt before reading each line?<br>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 1, 2013 at 7:14 AM, Lyndon Maydwell <span dir="ltr">&lt;<a href="mailto:maydwell@gmail.com" target="_blank">maydwell@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 dir="ltr">Interact should be able to handle line-by-line interaction as per this example, it should even be able to handle the exit case thanks to laziness:<div>
<br></div><div><div>&gt; main :: IO ()</div><div>&gt; main = interact (unlines . map reverse . lines . untilexit)</div>

<div>&gt; </div><div>&gt; untilexit :: String -&gt; String</div><div>&gt; untilexit (&#39;e&#39;:&#39;x&#39;:&#39;i&#39;:&#39;t&#39;:_) = []</div><div>&gt; untilexit (c:t)               = c : untilexit t</div><div>&gt; untilexit []                  = []</div>


<div><br></div><div class="gmail_extra">There will be a lot of things that it won&#39;t be able to do however.</div><div><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 1, 2013 at 5:49 AM, Ovidiu D <span dir="ltr">&lt;<a href="mailto:ovidiudeac@gmail.com" target="_blank">ovidiudeac@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>My problem with interact was that it doesn&#39;t give me the line when the user hits enter but instead it gives me all the lines at once when stdin is closed (unless I did something wrong)<br>


<br></div>
The other problem is that I want to stop the command processing when the user types the command &quot;exit&quot; and it seems interact can&#39;t do that.<br></div><div><div><div class="gmail_extra"><br>

<br><div class="gmail_quote">
On Sun, Mar 31, 2013 at 2:52 PM, Lyndon Maydwell <span dir="ltr">&lt;<a href="mailto:maydwell@gmail.com" target="_blank">maydwell@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



<div dir="ltr">Depending on what you&#39;re doing with the lines, it may be worth checking out the `interact` function as well :-)</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Mar 31, 2013 at 7:42 PM, Kim-Ee Yeoh <span dir="ltr">&lt;<a href="mailto:ky3@atamo.com" target="_blank">ky3@atamo.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Sun, Mar 31, 2013 at 5:19 PM, Ovidiu D &lt;<a href="mailto:ovidiudeac@gmail.com" target="_blank">ovidiudeac@gmail.com</a>&gt; wrote:<br>






&gt; I would like to make this function to have the signature<br>
&gt; f : IO [String]<br>
&gt; ...such that I can get rid of the IO monad and pass the pure string list to<br>
&gt; the processing function.<br>
<br>
</div>You could use:<br>
<br>
getContents &gt;&gt;= lines :: IO [String]<br>
<span><font color="#888888"><br>
-- Kim-Ee<br>
</font></span><div><div><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div></div></div></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>