śĪ!åŁN§      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦None=?M shell-monadAn arbitrary value. shell-monad=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.NThe single quotes are omitted for simple values that do not need any quoting. shell-monadEA 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 .None&'4=>?GHSVX՚u shell-monad7This 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. shell-monadnegation shell-monad§ shell-monadØ shell-monad© shell-monadŖ shell-monad« shell-monad¬ shell-monad­ shell-monad® shell-monadÆ  shell-monad°! shell-monad±" shell-monad²# shell-monad³$ shell-monad“% shell-monad#OR of the bits of the two arguments& shell-monad$XOR of the bits of the two arguments' shell-monad$AND of the bits of the two arguments( shell-monadRshift left (first argument's bits are shifted by the value of the second argument)) shell-monad shift right* shell-monadYif the first argument is non-zero, the result is the second, else the result is the third+ shell-monadjNote that this should only include things that test(1) and shell built-in test commands support portably.D shell-monad”Any 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.K shell-monadZClass of values that provide a hint for the name to use for a shell variable or function.0If you don't want to provide a naming hint, use (). v1 <- _ () To provide a naming hint, use L. v1 <- _ (L "x") L shell-monadUSuggests that a shell variable or function have its name contain the specified Text.N shell-monadĮ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 µ. (cmd "rmdir" (WithVar name ("/home/" <>))P shell-monad\The output of a command, or even a more complicated Script can be passed as a parameter to \ Examples: „cmd "echo" "hello there," (Output (cmd "whoami")) cmd "echo" "root's pwent" (Output (cmd "cat" "/etc/passwd" -|- cmd "grep" "root"))R shell-monad/Allows a function to take any number of Params.S shell-monadCA Param is anything that can be used as the parameter of a command.¶ shell-monadrEnvironment built up by the shell script monad, so it knows which environment variables and functions are in use.T shell-monadShell script monad.· shell-monadSpecifies a redirection.ø shell-monadredirect the fd to a file¹ shell-monadappend to fileŗ shell-monaduse a file as input» shell-monadredirect first fd to the second¼ shell-monadsame, but for input fd½ shell-monaduse a here document as input¾ shell-monadA shell expression.æ shell-monad9a command. may have a local environment to be added to itĄ shell-monadEshell code that is not able to a have a local environment added to itĮ shell-monad2named script with a local environment to add to itĀ shell-monad a commentĆ shell-monadexpressions run in a sub-shellÄ shell-monadexpressions run in a groupÅ shell-monad(Piping the first Expr to the second ExprĘ shell-monad&&Ē shell-monad||Č shell-monad#Redirects a file handle of the ExprÉ shell-monadA shell function.U shell-monadUsed for a static value.V shell-monad#Used to represent a shell variable.W shell-monad4A term that can be expanded in a shell command line.X shell-monadTreats the Text as a glob.When used as a S> to a command, it expands to one parameter per matching file. CforCmd (cmd "ls" (glob "*/*.cabal")) $ \file -> cmd "echo" fileWhen used in a q#, it matches text against the glob.Ļ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.Ź shell-monadIndents an ExprĖ shell-monad+Runs the monad and generates a list of ExprĢ shell-monadIRuns the monad, and returns a list of Expr and the modified environment.Ķ shell-monadbRuns the passed Script, using the current environment, and returns the list of Expr it generates.Y shell-monadPGenerates a shell script, including hashbang, suitable to be written to a file.Ī shell-monad!Formats an Expr to shell script.:Can generate either multiline or single line shell script.Ļ shell-monad'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.Š shell-monad]Finds an approriate marker to end a here document; the marker cannot appear inside the text.Z shell-monad&Generates a single line of shell code.[ shell-monad#Adds a shell command to the script.\ shell-monad$Variadic and polymorphic version of [-A command can be passed any number of Params. kdemo = script $ do cmd "echo" "hello, world" name <- newVar () readVar name cmd "echo" "hello" nameFor the most efficient use of \h, 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"Ń shell-monadAdds an Expr to the script.] shell-monad>Adds a comment that is embedded in the generated shell script.^ shell-monad5Makes a Static Term from any value that can be shown._ shell-monad=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.` shell-monadDCreates a new shell variable with an initial value coming from any S. For example, ²packageName <- newVarFrom (Output $ cmd "grep" "-i" "name\\s*:" (glob "*.cabal") -|- cmd "perl" "-pe" "s/^name\\s*:\\s*//i") (NamedLike "packageName")Use this with N= to store to modified value of a variable in a new variable. Phome <- globalVar "HOME" cabalDir <- newVarFrom (WithVar home (<> "/.cabal")) ()4Or to capture the output of an arithmetic operation. &sum <- newVarFrom (val x `APlus` 1) ()a shell-monad]Creates 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) (NamedLike "i")b shell-monad(Sets the Var to the value of the param. c shell-monad9Gets a Var that refers to a global variable, such as PATHd shell-monadQThis 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)e shell-monadŒ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:" positionalParametersŅ shell-monadŻCreates 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.f shell-monadµ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.g shell-monad›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.h shell-monadł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.i shell-monad: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 Xh, 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.j shell-monadTGenerates 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.k shell-monadVDefines 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: ’Xdemo = script $ do hohoho <- mkHohoho hohoho (static 1) echo "And I heard him exclaim, ere he rode out of sight ..." hohoho (static 3) mkHohoho :: Script (Term Val Int -> Script ()) mkHohoho = func (NamedLike "hohoho") $ do num <- takeParameter forCmd (cmd "seq" "1" num) $ \_n -> cmd "echo" "Ho, ho, ho!" "Merry xmas!"l shell-monadFRuns the command, and separates its output into parts (using the IFS)BThe action is run for each part, passed a Var containing the part.m shell-monadBAs long as the first Script exits nonzero, runs the second script.n shell-monadif with a Script conditional.EIf the conditional exits 0, the first action is run, else the second.o shell-monadwhen with a monadic conditionalp shell-monad!unless with a monadic conditionalq shell-monadQMatches the value of the Var against the Quoted Text (which can be generated by X?), and runs the Script action associated with the first match. sarg <- takeParameter () caseOf arg [ (quote "-h", showHelp) , (glob "-*", cmd "echo" "Unknown option:" arg) ]r shell-monad"Runs the script in a new subshell.s shell-monad;Runs the script as a command group in the current subshell.t shell-monad6Add a variable to the local environment of the script.Ó shell-monadBCreates 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 indentation, as well as making the single line formatting work.u shell-monad-Fills a variable with a line read from stdin.v shell-monad™By default, shell scripts continue running past commands that exit nonzero. Use 'stopOnFailure True' to make the script stop on the first such command.w shell-monad'Makes a nonzero exit status be ignored.x shell-monadPipes together two Scripts.y shell-monadANDs two Scripts.z shell-monadORs two Scripts.{ shell-monad3Redirects to a file, overwriting any existing file.(For example, to shut up a noisy command: cmd "find" "/" |> "/dev/null"| shell-monad?Appends to a file. (If file doesn't exist, it will be created.)} shell-monad%Redirects standard input from a file.~ shell-monad&Redirects a script's output to stderr. shell-monad<Redirects the first file descriptor to output to the second.6For example, to redirect a command's stderr to stdout: cmd "foo" &stdError>&stdOutput€ shell-monad=Redirects the first file descriptor to input from the second. For example, to read from Fd 42: cmd "foo" &stdInput<&Fd 42 shell-monad Helper for  and €‚ shell-monad@Provides the Text as input to the Script, using a here-document.ƒ shell-monadDCreates a Script that checks a Test and exits true (0) or false (1).-Useful with ifCmd, whenCmd, etc; for example: *ifCmd (test (FileExists "foo")) (foo, bar)„ shell-monadLifts a Term to Arith.Ž shell-monad'Quoted Text arguments are passed as-is.’ shell-monad*String arguments are automatically quoted.“ shell-monad(Text arguments are automatically quoted.– shell-monad6Allows passing the output of a command as a parameter.— shell-monadSAllows modifying the value of a shell variable before it is passed to the command. shell-monad Note that Ō, Õ, and Ö cannot be used with Arith.ž shell-monad‰Arith is an instance of Num, which allows you to write expressions like this with shell variables, that generate Arithmetic Expressions. val x * (100 + val y)Ÿ shell-monad7Allows passing an Arithmetic Expression as a parameter.v !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„vTYZWVUX[\SRPQLMK^_`abcdefgjiHIJEFGNOklmnopqrstxyzD{|}~€‚vwhƒ+,-./0123456789:;<=>?@ABC„ !"#$%&'()*]u×      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNNOOPPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø¦§©¦§Ŗ¦«¬¦«­®Æ°¦±²¦±³®Æ“®Æµ®Æ¶®Æ·®Æø®Æ¹¦ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×Ų٦ŚŪ¦ŚÜ¦ŚŻŽ(shell-monad-0.6.9-JqhiRFRaVTNIsD72cqzwutControl.Monad.Shell.QuoteControl.Monad.ShellValQuotablequoteQuotedQgetQ$fIsStringQuoted $fQuotable[]$fQuotableText $fQuotableVal$fQuotableVal0$fQuotableVal1 $fEqQuoted $fOrdQuoted $fShowQuoted$fSemigroupQuoted$fMonoidQuotedArithANumAVarAStaticANegateAPlusAMinusAMultADivAModANotAOrAAndAEqual ANotEqualALTAGTALEAGEABitOrABitXOrABitAnd AShiftLeft AShiftRightAIfTestTNotTAndTOrTEmpty TNonEmpty TStrEqual TStrNotEqualTEqual TNotEqualTGTTLTTGETLE TFileEqual TFileNewer TFileOlder TBlockExists TCharExists TDirExists TFileExistsTRegularFileExistsTSymlinkExists TFileNonEmptyTFileExecutable RedirFile Direction FromBeginningFromEnd Greediness ShortestMatch LongestMatch NameHinted NamedLikeWithVarOutput CmdParamsParamScriptStaticVarTermglobscript linearScriptruncmdcommentstaticnewVar newVarFromnewVarContainingsetVar globalVarpositionalParameters takeParameter defaultVarwhenVar errUnlessVartrimVar lengthVarfuncforCmdwhileCmdifCmdwhenCmd unlessCmdcaseOfsubshellgroupwithEnvreadVar stopOnFailure ignoreFailure-|--&&--||-|>|>>|<toStderr>&<&& hereDocumenttestval $fNamedFunc$fNamedVarName $fMonoidEnv$fSemigroupEnv $fMonadScript$fApplicativeScript$fNamedUntypedVar $fNumTerm $fNamedTerm $fParamQuoted $fParamTerm $fParamTerm0$fParamUntypedVar $fParam[] $fParamText$fCmdParamsScript $fCmdParams-> $fParamOutput$fParamWithVar$fNameHintedMaybe$fNameHintedNamedLike$fNameHinted()$fRedirFile(,) $fRedirFile[] $fEnumArith $fNumArith $fParamArith $fEqVarName $fOrdVarName $fShowVarName$fEqFunc $fOrdFunc $fShowFunc$fFunctorScriptbaseGHC.Num+-*GHC.Real/modghc-prim GHC.Classesnot Data.Foldableorand==/=<><=>=GHC.BasemappendEnv RedirSpec RedirToFileRedirToFileAppend RedirFromFile RedirOutput RedirInput RedirHereDocExprCmdRawEnvWrapCommentSubshellGroupPipeAndOrRedirFuncindentgen runScriptrunMfmtredirFd eofMarkeradd newVarUnsafeblockGHC.EnumfromEnum enumFromToenumFromThenTo