Copyright (c) 2006 John Goerzen, firstname.lastname@example.org
Welcome to HSH, the Haskell Shell infrastructure.
HSH is designed to let you mix and match shell expressions with Haskell programs.
Here are a few examples to get you started:
run $ "echo /etc/pass*" :: IO String -> "/etc/passwd /etc/passwd-" runIO $ "ls -l" -|- "wc -l" -> 12 runIO $ "ls -l" -|- wcL -> 12 runIO $ ("ls", ["-l", "file with spaces.txt"]) glob "~jgoerzen" >>= cd . head
wcL is a pure Haskell function defined in HSH.ShellEquivs.wcL as:
wcL :: [String] -> [String] wcL inp = [show $ genericLength inp]
Here's another example:
let countLines = (zipWith (\i line -> printf "%-5d %s" i line) [(1::Int)..])::([String] -> [String]) runIO $ ("ls", ["-l"]) -|- countLines -|- filter (isSuffixOf "hs") 6 -rw-r--r-- 1 jgoerzen jgoerzen 1285 Jun 6 09:43 HSH.hs 11 -rw-r--r-- 1 jgoerzen jgoerzen 565 Jun 6 09:43 test.hs
You can run a command with HSH in several ways:
You can then specify a command, which could be a single command or a command joined together with pipes.
There are many different items that make valid types; see the list of instances of ShellCommand for a full list. Here are a few:
Pipes can be constructed by using the -|- operator, as illustrated above. It is quite possible to pipe data between Haskell functions and shell commands at will.
In addition, HSH.ShellEquivs provides a number of useful pure-Haskell equivalents of regular shell commands.
For more information, please consult the other modules in HSH as well as the HSH wiki at:
|Produced by Haddock version 0.8|