[Haskell-cafe] wanted: haskell one-liners (in the perl sense of one-liners)

Thomas Hartman tphyahoo at gmail.com
Fri Mar 2 08:48:23 EST 2007

Okay, I am aware of


which gives some implementation of simple unix utilities in haskell.

But I couldn't figure out how to use them directly from the shell, and
of course that's what most readers will probably wnat.

Or let me put it another way.

Is there a way to do

  find -maxdepth 1 -type f | xargs du | perl -ane 'print "\$F[0]\n"' |
perl -e '$sum += $_ while <>; print "$sum\n"'

as a shell command that idiomatically uses haskell?

For non-perlers, that sums up the disk usage of all files in the
current directory, skipping subdirs.

print "\$F[0]\n

looks at the first (space delimited) collumn of output.

perl -e '$sum += $_ while <>; print "$sum\n"'

, which is I guess the meat of the program, sums up all the numbers
spewed out of the first column, so in the end you get a total.

So, anyone out there want to establish a haskell one liner tradition?



More information about the Haskell-Cafe mailing list