[Haskell-cafe] How to print a string (lazily)

Daniel Carrera daniel.carrera at zmsl.com
Tue Jan 3 13:15:54 EST 2006


Neil Mitchell wrote:
> All Haskell functions are lazy, hence there is no need to "write a
> lazy version" of your print_list function. I think the function you
> probably want is:
> 
> putStr (unlines xs)

Hhmm... that does work, and I'm a bit surprised that it does. I guess 
I'm still stuck in the eager computation mindset. I would expect putStr 
to have to wait for the (unlines xs) to be finished before doing any 
printing, but it doesn't.

Some day I'll get the hang of this lazy evaluation thing. :)

> The first one has fewer monads, so I prefer it, but take your pick :)

Monads scare me, so I'll pick the first :)  Thanks!

Cheers,
Daniel.
-- 
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /


More information about the Haskell-Cafe mailing list