<div dir="ltr"><div>Right. I definitely want the lazy behavior.<br><br></div>Thanks<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 31, 2013 at 1:29 PM, Brent Yorgey <span dir="ltr"><<a href="mailto:byorgey@seas.upenn.edu" target="_blank">byorgey@seas.upenn.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Unfortunately, with the definition<br>
<br>
f = getLine : f<br>
<br>
this will not work. 'sequence f' has to do *ALL* the IO before you<br>
can process even the first String in the resulting list. Since it is<br>
infinite, it will just sit there reading lines forever but never<br>
letting you process them.<br>
<br>
I think in this case using [IO String] is actually a good solution.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Brent<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Sun, Mar 31, 2013 at 12:24:33PM +0200, Nathan Hüsken wrote:<br>
> Try<br>
><br>
> sequence :: Monad m => [m a] -> m [a]<br>
><br>
> I thinkg<br>
><br>
> sequence f :: IO [String]<br>
><br>
> should be what you want.<br>
><br>
> On 03/31/2013 12:19 PM, Ovidiu D wrote:<br>
> >I have the function f which reads lines form the stdin and looks like this:<br>
> ><br>
> >f :: [IO String]<br>
> >f = getLine : f<br>
> ><br>
> >What I don't like is the fact that the line processing I'm doing will<br>
> >have to be in the IO Monad<br>
> ><br>
> >I would like to make this function to have the signature<br>
> >f : IO [String]<br>
> >...such that I can get rid of the IO monad and pass the pure string list<br>
> >to the processing function.<br>
> ><br>
> >Can I do this?<br>
> ><br>
> >Thanks<br>
> ><br>
> ><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>
><br>
><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>
_______________________________________________<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>
</div></div></blockquote></div><br></div>