On Fri, Jun 22, 2007 at 04:53:42PM +0100, Malcolm Wallace wrote:
> "Olivier Boudry" <[EMAIL PROTECTED]> wrote:
> 
> > I did this replacing:
> >    (putStrLn . unlines . concat) origLinks
> > with
> >    (putStrLn . unlines . take 10 . concat) origLinks
> 
> Unfortunately, 'origLinks' has already been computed in full, before the
> 'take 10' applies to it.  Why?  Because 'origLinks' is the result of an
> I/O action, which forces it:
> 
> > main = do ...
> >           origLinks <- mapM (getLinksAfterImgByAttr ...) picLinks
> 
> What you really want to do is to trim the picLinks before you download
> them. e.g.
> 
> > main = do ...
> >           origLinks <- mapM (getLinksAfterImgByAttr ...) (take 10 picLinks)

Or make this lazy with:

> main = do ...
>           origLinks <- mapM (unsafeInterleaveIO . getLinksAfterImgByAttr ...) 
> picLinks
-- 
David Roundy
Department of Physics
Oregon State University
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to