[Haskell-cafe] A round of golf

Bryan O'Sullivan bos at serpentine.com
Thu Sep 18 13:25:35 EDT 2008

On Thu, Sep 18, 2008 at 10:02 AM, Creighton Hogg <wchogg at gmail.com> wrote:

> If this makes anyone cringe or cry "you're doing it wrong", I'd
> actually like to hear it.

Yes, that made me cry :-)  Your code seems very convoluted, and quite
successfully hides what it's really trying to do. Here's a version that is
rather more concise, and which will be far faster besides.

import qualified Data.ByteString.Lazy.Char8 as B
import System.Environment

main = mapM_ ((print =<<) . fmap (B.count '\n') . B.readFile) =<< getArgs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080918/fb685d41/attachment.htm

More information about the Haskell-Cafe mailing list