[Haskell-cafe] Conditional IO ?

Arlen Cuss celtic at sairyx.org
Mon Jun 20 10:08:03 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 20/06/11 18:00, Dmitri O.Kondratiev wrote:
> Hi,
> What is right way to do conditional IO?
> For example, I need to write to file errors only in case they exist,
> otherwise my function should do nothing:
> 
> handleParseErrors errors
>   | (not . null) errors =  writeFile "parse-errors.txt" (show errors)
>   | otherwise = ?
> 
> What should be an 'otherwise' case ?

How about `return ()'?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJN/v/hAAoJEDiWqExGnQ/Q7VQP/js4XZc92bHeM8f/ErQeQ4LT
UwINtt8WFtTWevQtwfO6wNc96CVcjnybb2SwPqnQMISnb4EPc9RvfFz24FTBneQ9
d7MD44uNnW1wAgY8VKaQQJ2v5VVrUd8Gq/m0toUKuefaT9yKMVIG/EeEPaLEUe3y
tJUyykCXcUpTzllDyk9kjb/1Og9CNWD+y4rdrWSldWCwgIPMHE2nwNOvs6RquPDQ
Om5eFdk2AFwAgDl1FIR2EiuWdQ3jUVPaDsHC0L24fvCeC/TA6AoHmC0panCYCchc
8nEruqwmiA/nU+Uh1Z6SWEicBeuWcXSk6iPuRYM7xU9dDLKFNEHAvCTLYdg2+zwR
sovOOYrOEnQ8FDwyZGXC7atxrNGl/nk09Q2RNkXryGo/nNdkUG0AuvoXI5gn8Q6v
7mZiXJr2AbUFqcDA4qXOj8IwddtU5hvwqkGj7xSqCck9sHWWXjZLrJqFH+mW8oMU
8rHVkSpMEFH0vbfvvgRMqzdcpnuDKa4/t+o8wvJy/lr9pdhP2o2azpxvb6NFlDpP
dgDwnOe/v8c9Mz7tqs41k94SYTVk2lNpsoXShVoB9tg0EttHKjDNM2ykGJl90Hcf
6vJUGEyNqE78s6qMxiAauxatlQdkw40j2ifcriElj5U7cogpZUGxnb/RODsl0rqn
BHPJVkHC/iEQ+t/4lfaT
=HGbC
-----END PGP SIGNATURE-----



More information about the Haskell-Cafe mailing list