For all haskell-loving folks out they, consider these lines as an addon to your .bashrc:
if which ghc >/dev/null
then
function hmap { ghc -e "interact ($*)"; }
function hmapl { hmap "unlines.($*).lines" ; }
function hmapw { hmapl "map (unwords.($*).words)" ; }
fi
This is somewhat an replacement to "perl -e", for cases where haskell does the job nicer. So, you like triangular text files? Then try
cat /etc/passwd | hmapl zipWith take [1..]
In most cases, you want to run hmapl with map or filter as the first argument, e.g.
cat /etc/passwd | hmapl map reverse
w|hmapl 'filter (List.isPrefixOf "j")' # essentially grep ^j
man ghc|hmapw 'filter (all Char.isAlpha)'
Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.
http://www.nabble.com/wanted%3A-haskell-one-liners-%28in-the-perl-sense-of-one-liners%29-tf3333697.html