I think I could have most of the oneliner goodness of h4sh, without having to do the module install, if I could figure out a way to include modules with ghc -e.

i confess myself to be among those who underappreciated ghc -e, until this 
thread:)

as Joachim said (thanks for starting this, btw;-), we can use qualified names

   $ echo hello world | hmap 'map Char.toUpper'
   HELLO WORLD

and to get at your other methods, the question is not how to include modules
with ghc -e; instead, recall that ghc -e supplies a command to be evaluated
within the context of its parameter module (single input for a ghci session):

   $ cat Imports.hs
   import Debug.Trace
   helper x = trace "hi there" (x+1)

   $ ghc -e 'helper 41' Imports.hs
   hi there
   42

as to the original question in this thread, my .bashrc now also has a few less
symmetric entries:

          function hrunl { ghc -e "interact(show.($*).lines)";  }
          function hrunw { ghc -e "interact(show.($*).words)";  }
          function hrunwl { ghc -e "interact(show.($*).map words.lines)";  }

using which the one-liner becomes something like

   find -maxdepth 1 -type f | xargs du | hrunwl "sum . map (read . head)"

(the find/du is better left in shell tool land, it seems, and default Num is 
Integer)

hth,
claus

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to