[Haskell-cafe] Software Tools in Haskell

Neil Mitchell ndmitchell at gmail.com
Wed Dec 12 14:03:45 EST 2007


> main = do (print . showln . length) =<< getContents
>    where showln a = show a ++ "\n"

This can be written better. print puts a newline at the end and does a
show, so lets remove that bit:

main = do (print . length) =<< getContents

Now we aren't using do notation, despite having a do block, and the
brackets are redundant:

main = print . length =<< getContents

Much nicer :-)



More information about the Haskell-Cafe mailing list