[Haskell-cafe] Code walking off the right edge of the screen
deniz.a.m.dogan at gmail.com
Sat Jun 20 14:51:00 EDT 2009
2009/6/20 Stephan Friedrichs <deduktionstheorem at web.de>:
> Deniz Dogan wrote:
>> I (too) often find myself writing code such as this:
>> if something
>> then putStrLn "howdy there!"
>> else if somethingElse
>> then putStrLn "howdy ho!"
>> else ...
>> So how do I make code like this prettier?
> If it's a function, you can use guards:
> foo :: ...
> foo something somethingElse
> | something -> putStrLn "howdy there!"
> | somethingElse -> putStrLn "howdy ho!"
> | otherwise -> ...
Good idea, I hadn't thought of that... Currently this is all in the
main function, checking the command line arguments. I suppose I could
put it in a separate function. Thanks!
More information about the Haskell-Cafe