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

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Jan 3 16:23:54 EST 2006

On Tue, Jan 03, 2006 at 05:49:07PM +0000, 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)
> This uses the bulid in unlines function, which is similar in spirit to
> join (you get more quotes, which I guess you don't want)
> The equivalent in monad'y programming is:
> mapM putStrLn xs
> The first one has fewer monads, so I prefer it, but take your pick :)

Nitpicking a bit to prevent possible confusion: a monad is a *type
constructor*, not an expression. In both variants above you are dealing
with two monads - IO and [] - however, the Monad instance for [] is
not used.

Best regards

I am searching for programmers who are good at least in
(Haskell || ML) && (Linux || FreeBSD || math)
for work in Warsaw, Poland

More information about the Haskell-Cafe mailing list