Index of /~pls/repos/h4sh
      Name                    Last modified       Size  Description

[DIR] Parent Directory 04-Nov-2009 14:46 - [DIR] H4SH/ 04-Nov-2009 14:46 - [DIR] _darcs/ 04-Nov-2009 14:46 - [DIR] testsuite/ 04-Nov-2009 14:46 - [   ] AUTHORS 14-Aug-2005 15:48 1k [TXT] Setup.hs 02-May-2006 19:00 1k [   ] Makefile 02-May-2006 19:00 1k [   ] HOWTO 04-Sep-2005 14:00 2k [   ] DOC 04-Sep-2005 14:00 3k [TXT] Build.hs 02-May-2006 19:00 14k [TXT] Command.hs 02-May-2006 19:00 14k [   ] LICENSE 14-Aug-2005 15:48 19k


        > make (GNU or BSD)
        > The Glasgow Haskell Compiler
        > Cabal
        > hs-plugins:
                darcs get
        > fps 0.5:
                darcs get

        > PREFIX=/tmp make
        > make install

        > make check  (you may need to adjust the variable `GM4' in the
                       toplevel Makefile, or in the environment)



Unix is all about programs that do one thing, and one thing well.
Unfortunately, over time, the common unix text processing commands have
become bloated and silly, with rather arbitrary features for programs
that should have simple semantics (consider uniq and wc outputting
leading space, or cut indexing fields from 1).

On the other hand Haskell has a powerful and beautiful List library for
processing text. By exposing the Haskell List library as a set of shell
utilities, and utlising function composition via pipes, we can program
in the shell using these precise, clean Haskell functions.

To this end, h4sh makes the functions of this library available as unix
shell commands. 

For example:
        take 100 data | map show.length | sort | reverse | head

Commands are generated from a description of their type. h4sh utilities
thus have standard behaviour, for example, all functions read from stdin
or file arguments (meaning that `id' is equivalent `cat'), and arguments
are handled in the order they appear in the function type signature.

h4sh currently compiles functions of the following types:

        a      -> a
        a     -> [a]
        [a]   -> a
        [a]   -> Int
        [a]   -> [a]
        [[a]] -> [a]
        a     -> [a]  -> [a]
        a     -> [a]  -> [Int]
        Int   -> [a]  -> [a]
        [a]   -> [a]  -> [a]
        (a -> a)      -> a   -> a
        (a -> a)      -> a   -> [a]
        (a -> a)      -> [a] -> [a]
        (a -> a)      -> [a] -> a
        (a -> Bool)   -> [a] -> [a]
        (a -> a -> a) -> [a] -> a
        (a -> Maybe (a, a))  -> a -> [a]

The following functions are provided as shell commands:

        (!!) ($) (++) (:) (\\)
        concat concatMap cycle
        delete drop dropWhile
        elemIndices filter foldl
        foldr group head id init
        insert intersect intersperse
        iterate last length map
        maximum minimum nub repeat
        reverse show sort tail
        take takeWhile transpose
        unfoldr union words zip

Higher order functions like map are handled using runtime evaluation,
provided by the hs-plugins library, allowing arbitrary Haskell code to
be evaluated, e.g. for map and filter.

h4sh also provides a library H4SH.List of useful String and Regex

h4sh was written during a cold, but sunny weekend in August 2005.