<div dir="ltr">Here is the answer<div><br></div><div><a href="http://stackoverflow.com/questions/34910992/iterate-io-actions-and-laziness">http://stackoverflow.com/questions/34910992/iterate-io-actions-and-laziness</a><br></div><div><br></div><div>You need to write recursive function, not to use iterage or to </div><div><br></div><div>liftM (take 5) $ sequence $ repeat (unsafeInterleaveIO getLine)<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 6, 2016 at 11:38 AM, Nicolaas du Preez <span dir="ltr"><<a href="mailto:njdupreez@yahoo.com" target="_blank">njdupreez@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Good day All,<div><br></div><div>Why does</div><div><br></div><div><span style="font-family:Menlo;font-size:11px"> liftM (take 5) $ sequence $ repeat getLine</span></div><div><br></div><div>not stop at reading only 5 lines from stdin but keeps on reading more?</div><div><br></div><div>What I’m really trying to achieve is to get input from the user until</div><div>an empty line is read with the code below. But this doesn’t work </div><div>as I expected, similar to the above.</div><div><br></div><div><span style="font-size:11px;font-family:Menlo"> liftM (takeWhile (/= "")) $ sequence $ repeat getLine</span></div><div><span style="font-family:Menlo;font-size:11px"><br></span></div><div><br></div><div>Regards,<div>Nicolaas du Preez</div></div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>