[Haskell-cafe] How to print a string (lazily)
Tomasz Zielonka
tomasz.zielonka at gmail.com
Wed Jan 4 01:21:13 EST 2006
On Tue, Jan 03, 2006 at 10:28:54PM +0100, Udo Stenzel wrote:
> Daniel Carrera wrote:
> > print_list [] = do putStr ""
>
> This looks as if you're confused. The keyword "do" is completely
> redundant. "do" does not mean "please ignore all rules and allow side
> effects", it rather means "please build a new action by sequencing what
> follows". So "do" with only one action after it is useless (and a sign
> of confusion).
Perhaps you are right, but this can also be a sign of version-control
awareness, and I know Daniel uses darcs.
I often place a single command in a do-block, because I want future
changes to touch as little lines as possible. Consider:
f = putStrLn "b"
and
f = do
putStrLn "b"
If you'll later add more commands, you'll get something like:
f = do
x <- g
putStrLn "b"
putStrLn x
which is much closer to the reduntant-do variant.
Best regards
Tomasz
--
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