microlens-process-0.2.0.1: Micro-optics for the process library

Copyright2019 Emily Pillmore
LicenseBSD
MaintainerEmily Pillmore <emilypi@cohomolo.gy>
StabilityExperimental
PortabilityTypeFamilies
Safe HaskellSafe
LanguageHaskell2010

System.Process.Microlens.CmdSpec

Contents

Description

This module provides the associated optics and combinators for working with CmdSpec objects. CmdSpec consists of two cases: a Shell command, which is a command to execute naively in the shell, and a Raw command which is a command path together with its arguments.

CmdSpec has two cases, and therefore a Traversal into those two cases. There is also a convenient Traversal available for working with the arglist of a Raw command and combinators for working with arguments monoidally.

We provide classy variants for all useful traversals

Synopsis

Traversals

_RawCommand :: Traversal' CmdSpec (FilePath, [String]) Source #

A Traversal' into the RawCommand case of a CmdSpec

Examples:

>>> RawCommand "/bin/ls" ["-l"] ^? _RawCommand
Just ("/bin/ls",["-l"])
>>> RawCommand "/bin/ls" ["-l"] ^? _ShellCommand
Nothing
>>> RawCommand "/bin/ls" ["-l"] ^. _RawCommand . _1
"/bin/ls"
>>> RawCommand "/bin/ls" ["-l"] ^. _RawCommand . _2
["-l"]

_ShellCommand :: Traversal' CmdSpec String Source #

A Traversal' into the ShellCommand case of a CmdSpec

Examples:

>>> ShellCommand "ls -l" ^? _ShellCommand
Just "ls -l"
>>> RawCommand "/bin/ls" ["-l"] ^? _ShellCommand
Nothing

arguments :: Traversal' CmdSpec [String] Source #

Traversal' into the arguments of a command

Examples:

>>> RawCommand "/bin/ls" ["-l"] ^. arguments
["-l"]

Classy Traversals

class IsShell a where Source #

Classy Traversal' into the shell command of a CmdSpec

class IsRaw a where Source #

Classy Traversal' into the raw command of a CmdSpec

Instances
IsRaw CmdSpec Source # 
Instance details

Defined in System.Process.Microlens.CmdSpec

Combinators

arguing :: String -> CmdSpec -> CmdSpec Source #

Append an argument to the argument list of a RawCommand

Examples:

>>> arguing "-h" $ RawCommand "/bin/ls" ["-l"]
RawCommand "/bin/ls" ["-l","-h"]
>>> arguing "-h" (RawCommand "/bin/ls" ["-l"]) ^. arguments
["-l","-h"]