[Haskell-cafe] csv one-liner

Claus Reinke claus.reinke at talk21.com
Wed Oct 1 17:31:22 EDT 2008


>>> (writeFile "output.csv") =<< (liftM printCSV $ liftM (map
>>> updateLine) $ parseCSVFromFile "input.csv")
> 
>> Um... Does anybody else find it interesting that we are "showing the
>> beauty of Haskell" by attempting to construct the most terse, cryptic,
>> unmaintainable tangle of point-free code
> 
> I don't agree at all!  How could a pipeline like this possibly be more
> clearly expressed than by the pattern: 
> 
>   readInputFile "input" >>= mungeStuff >>= writeOutputFile "output"

    interact pureMungeStuff

After all, you're looking for oneliners, not real programs.

    interact $ either (error . show) (printCSV . map updateLine) . parseCSV "<stdin>" 

Claus

-- some people need a vacation




More information about the Haskell-Cafe mailing list