-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | shell monad -- -- This is a shell monad, for generating shell scripts. @package shell-monad @version 0.0.1 -- | A shell script monad module Control.Monad.Shell -- | Shell script monad. data Script a -- | Generates a shell script, including hashbang, suitable to be written -- to a file. script :: Script f -> Text -- | Generates a single line of shell code. linearScript :: Script f -> Text -- | A shell variable. data Var -- | Expand a shell variable to its value. val :: Var -> Q -- | A shell expression. data Expr -- | Indents an Expr indent :: Expr -> Expr -- | Adds a shell command to the script. run :: Text -> [Text] -> Script () -- | Variadic argument version of run. -- -- The command can be passed any number of arguments. As well as passing -- Text arguments, it also accepts Var arguments, which passes the value -- of a shell variable to the command. -- -- Convenient usage of cmd requires the following: -- --
--   {-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
--   {-# OPTIONS_GHC -fno-warn-type-defaults #-}
--   import Control.Monad.Shell
--   import qualified Data.Text.Lazy as T
--   default (L.Text)
--   
-- -- This allows writing, for example: -- --
--   demo = script $ do
--     cmd "echo" "hello, world"
--     name <- newVar "name"
--     readVar name
--     cmd "echo" "hello" name
--   
cmd :: ShellCmd result => Text -> result -- | Adds an Expr to the script. add :: Expr -> Script () -- | Adds a comment that is embedded in the generated shell script. comment :: Text -> Script () -- | Defines a new shell variable. -- -- The name of the variable that appears in the shell script will be -- based on provided name, but each call to newVar will generate a new, -- unique variable name. newVar :: Text -> Script Var -- | Creates a new shell variable, with an initial value. newVarContaining :: Text -> Text -> Script Var -- | Gets a Var that refers to a global variable, such as PATH globalVar :: Text -> Script Var -- | Defines a shell function, and returns an action that can be run to -- call the function. -- -- TODO parameter passing to the function func :: Script () -> Script (Script ()) -- | Runs the command, and separates its output into parts (using the IFS) -- -- The action is run for each part, passed a Var containing the part. forCmd :: Script () -> (Var -> Script ()) -> Script () -- | Quotes the value to allow it to be safely exposed to the shell. -- -- The method used is to replace ' with '"'"' and wrap the value inside -- single quotes. This works for POSIX shells, as well as other shells -- like csh. quote :: Text -> Q -- | Generates shell code to read a variable from stdin. readVar :: Var -> Script () -- | Pipes together two Scripts. (-|-) :: Script () -> Script () -> Script () instance Eq Var instance Ord Var instance Show Var instance Eq Q instance Ord Q instance Show Q instance Eq Func instance Ord Func instance Show Func instance f ~ () => ShellCmd (Script f) instance (CmdArg arg, ShellCmd result) => ShellCmd (arg -> result) instance CmdArg Q instance CmdArg Var instance CmdArg Text instance Monoid Env instance Monad Script instance Monoid Q