W      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVNone24BAn arbitrary value.=Quotes a 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.EA value that is safely quoted so that it can be exposed to the shell.eWhile the constructor is exposed, you should avoid directly constucting Quoted values. Instead, use .W:Any Showable value can be quoted, just use 'quote (Val v)' XYWZ[XYWZ[None -234=HKMi7This data type represents shell Arithmetic Expressions.Note that in shell arithmetic, expressions that would evaluate to a Bool, such as ANot and AEqual instead evaluate to 1 for True and 0 for False.Yif the first argument is non-zero, the result is the second, else the result is the third  shift right Rshift left (first argument's bits are shifted by the value of the second argument) $AND of the bits of the two arguments $XOR of the bits of the two arguments #OR of the bits of the two arguments\]^_`abcdefghinegationAny function that takes a RedirFile can be passed a a FilePath, in which case the default file descriptor will be redirected to/from the FilePath.xOr, it can be passed a tuple of (Fd, FilePath), in which case the specified Fd will be redirected to/from the FilePath.&ZClass of values that provide a hint for the name to use for a shell variable or function.QTo skip providing a hint, use '()'. To provide a hint, use '(NamedLike "name")'.'USuggests that a shell variable or function have its name contain the specified Text.)Allows modifying the value of a variable before it is passed to a command. The function is passed a Quoted Text which will expand to the value of the variable, and can modify it, by using eg j. (cmd "rmdir" (WithVar name ("/home/" <>))+\The output of a command, or even a more complicated Script can be passed as a parameter to 5 Examples: cmd "echo" "hello there," (Output (cmd "whoami")) cmd "echo" "root's pwent" (Output (cmd "cat" "/etc/passwd" -|- cmd "grep" "root"))-/Allows a function to take any number of Params..CA Param is anything that can be used as the parameter of a command.krEnvironment built up by the shell script monad, so it knows which environment variables and functions are in use./Shell script monad.lSpecifies a redirection.muse a here document as inputnsame, but for input fdoredirect first fd to the secondpuse a file as inputqappend to filerredirect the fd to a filesA shell expression.t#Redirects a file handle of the Expru||v&&w(Piping the first Expr to the second Exprxexpressions run in a sub-shelly a commentz a command{A shell function.02A shell variable, with an associated phantom type.|?Casts from any type of Var to any other type. Use with caution!1MTreats the Text as a glob, which expands to one parameter per matching file.The input is assumed to be a well-formed glob. Characters in it that are not alphanumeric and are not wildcard characters will be escaped before it is exposed to the shell. This allows eg, spaces in globs.}Indents an Expr~4runScriptuate the monad and generates a list of ExprJRuns the monad, and returns a list of Expr and the modified environment.bRuns the passed Script, using the current environment, and returns the list of Expr it generates.2PGenerates a shell script, including hashbang, suitable to be written to a file.!Formats an Expr to shell script.:Can generate either multiline or single line shell script.'Displays a Fd for use in a redirection.Redirections have a default Fd; for example, ">" defaults to redirecting stdout. In this case, the file descriptor number does not need to be included.]Finds an approriate marker to end a here document; the marker cannot appear inside the text.3&Generates a single line of shell code.4#Adds a shell command to the script.5$Variadic and polymorphic version of 4-A command can be passed any number of Params. odemo = script $ do cmd "echo" "hello, world" name <- newVar "name" readVar name cmd "echo" "hello" nameFor the most efficient use of 5h, add the following boilerplate, which will make string literals in your program default to being Text: {-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} import Control.Monad.Shell import qualified Data.Text.Lazy as L default (L.Text)Note that the command to run is itself a Param, so it can be a Text, or a String, or even a Var or Output. For example, this echos "hi": Odemo = script $ do echovar <- newVarContaining "echo" () cmd echovar "hi"Adds an Expr to the script.6>Adds a comment that is embedded in the generated shell script.7=Defines a new shell variable, which starts out not being set.>Each call to newVar will generate a new, unique variable name.LThe namehint can influence this name, but is modified to ensure uniqueness.8]Createa a new shell variable, with an initial value which can be anything that can be shown. ds <- newVarContaining "foo bar baz" (NamedLike "s") i <- newVarContaining (1 :: Int) (NamedLine "i")9(Sets the Var to the value of the param. :9Gets a Var that refers to a global variable, such as PATH;QThis special Var expands to whatever parameters were passed to the shell script.JInside a func, it expands to whatever parameters were passed to the func. (This is $@ in shell)<Takes the first positional parameter, removing it from positionalParameters and returning a new Var that holds the value of the parameter.QIf there are no more positional parameters, the script will crash with an error. For example: tremovefirstfile = script $ do cmd "rm" =<< takeParameter cmd "echo" "remaining parameters:" positionalParametersCreates a new shell variable, but does not ensure that it's not already set to something. For use when the caller is going to generate some shell script that is guaranteed to clobber any existing value of the variable.=Generates a new Var. Expanding this Var will yield the same result as expanding the input Var, unless it is empty, in which case it instead defaults to the expansion of the param.>Generates a new Var. If the input Var is empty, then this new Var will likewise expand to the empty string. But if not, the new Var expands to the param.?Generates a new Var. If the input Var is empty then expanding this new Var will cause an error to be thrown, using the param as the error message. If the input Var is not empty, then the new Var expands to the same thing the input Var expands to.@TGenerates a new Var, which expands to the length of the expansion of the input Var.[Note that 'lengthVar positionalParameters' expands to the number of positional parameters.A:Produces a Var that is a trimmed version of the input Var.aThe Quoted Text is removed from the value of the Var, either from the beginning or from the end.#If the Quoted Text was produced by 1h, it could match in multiple ways. You can choose whether to remove the shortest or the longest match.dThe act of trimming a Var is assumed to be able to produce a new Var holding a different data type.BVDefines a shell function, and returns an action that can be run to call the function.The action is variadic; it can be passed any number of CmdParams. Typically, it will make sense to specify a more concrete type when defining the shell function.The shell function will be given a unique name, that is not used by any other shell function. The namehint can be used to influence the contents of the function name, which makes for more readable generated shell code. For example: Mdemo = script $ do hohoho <- mkHohoho hohoho (Val 1) echo "And I heard him exclaim, ere he rode out of sight ..." hohoho (Val 3) mkHohoho :: Script (Val Int -> Script ()) mkHohoho = func (NamedLike "hohoho") $ do num <- takeParameter forCmd (cmd "seq" "1" num) $ \_n -> cmd "echo" "Ho, ho, ho!" "Merry xmas!"CFRuns the command, and separates its output into parts (using the IFS)BThe action is run for each part, passed a Var containing the part.DBAs long as the first Script exits nonzero, runs the second script.Eif with a monadic conditionalEIf the conditional exits 0, the first action is run, else the second.Fwhen with a monadic conditionalG!unless with a monadic conditionalHQMatches the value of the Var against the Quoted Text (which can be generated by 1?), and runs the Script action associated with the first match.BCreates a block such as "do : ; cmd ; cmd" or "else : ; cmd ; cmd"The use of : ensures that the block is not empty, and allows for more regular indetnetion, as well as making the single line formatting work.IDGenerates shell code to fill a variable with a line read from stdin.JBy default, shell scripts continue running past commands that exit nonzero. Use "stopOnFailure True" to make the script stop on the first such command.K'Makes a nonzero exit status be ignored.LPipes together two Scripts.MANDs two Scripts.NORs two Scripts.O3Redirects to a file, overwriting any existing file.(For example, to shut up a noisy command: cmd "find" "/" |> "/dev/null"P?Appends to a file. (If file doesn't exist, it will be created.)Q%Redirects standard input from a file.R&Redirects a script's output to stderr.S<Redirects the first file descriptor to output to the second.6For example, to redirect a command's stderr to stdout: cmd "foo" &stdError>&stdOutputT=Redirects the first file descriptor to input from the second. For example, to read from Fd 42: cmd "foo" &stdInput<&Fd 42U Helper for S and TV@Provides the Text as input to the Script, using a here-document.7Allows passing an Arithmetic Expression as a parameter.6Allows passing the output of a command as a parameter.'Quoted Text arguments are passed as-is.SAllows modifying the value of a shell variable before it is passed to the command.XVar arguments cause the (quoted) value of a shell variable to be passed to the command.-Any value that can be shown can be passed to 5; just wrap it inside a Val.*String arguments are automatically quoted.(Text arguments are automatically quoted.  !"#$%&'()*+,-.k/lmnopqrstuvwxyz{0|1}~23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVU  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVU/230145.-+,'(&789:;<=>@A#%$ "!)*BCDEFGHLMNOPQRSTUVJK? 6Ic  "!#%$&'()*+,-.k/lrqponmszyxwvut{0|1}~23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV      !"#$%&'())**++,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\][\^[\_[\`[\a[\bcdecdf[\gchichjcklckmckncopqrstuvwxyz{|}~q./shell-monad-0.5.0Control.Monad.Shell.QuoteControl.Monad.ShellValQuotablequoteQuotedQgetQArithACond AShiftRight AShiftLeftABitAndABitXOrABitOrAGEALEAGTALT ANotEqualAEqualAAndAOrANotAModADivAMultAMinusAPlusANegateAVarANum RedirFile DirectionFromEnd FromBeginning Greediness LongestMatch ShortestMatch NameHinted NamedLikeWithVarOutput CmdParamsParamScriptVarglobscript linearScriptruncmdcommentnewVarnewVarContainingsetVar globalVarpositionalParameters takeParameter defaultVarwhenVar errUnlessVar lengthVartrimVarfuncforCmdwhileCmdifCmdwhenCmd unlessCmdcaseOfreadVar stopOnFailure ignoreFailure-|--&&--||-|>|>>|<toStderr>&<&& hereDocument$fQuotableVal1 $fQuotableVal$fQuotableVal0 $fQuotable[]$fQuotableTextghc-prim GHC.Classes>=<=></===baseGHC.ListandornotGHC.Realmod/GHC.Num*-+ Data.MonoidmappendEnv RedirSpec RedirHereDoc RedirInput RedirOutput RedirFromFileRedirToFileAppend RedirToFileExprRedirOrAndPipeSubshellCommentCmdFunccastVarindentgen runScriptrunMfmtredirFd eofMarkeradd newVarUnsafeblock $fParamArith $fParamOutput $fParamQuoted$fParamWithVar $fParamVar $fParamVal $fParam[] $fParamText fromRedirFilehintedcmdAll toTextParamenvVarsenvFuncsVarName UntypedVarVvarName expandVar simpleVar modifyEnvVarsmodifyEnvFuncsshowFdtoLinearScriptnewVarContaining'modVarmodVar'ifCmd'combine toSingleExpredir fileRedirfmtArith$fRedirFile(,) $fRedirFile[]$fNameHintedMaybe$fNameHintedNamedLike$fNameHinted()$fCmdParamsScript$fCmdParams(->)$fParamUntypedVar $fMonoidEnv $fMonadScript