lens-process-0.4.0.0: Optics for system processes
Copyright(c) 2019-2021 Emily Pillmore
LicenseBSD
MaintainerEmily Pillmore <emilypi@cohomolo.gy>
StabilityExperimental
PortabilityTypeFamilies, Rank2Types
Safe HaskellNone
LanguageHaskell2010

System.Process.Lens.Optics

Description

Just the (classy) optics

Synopsis

Prisms

_ShellCommand :: Prism' CmdSpec String Source #

A prism into the ShellCommand case of a CmdSpec

Examples:

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

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

A prism 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"]

_Inherit :: Prism' StdStream () Source #

A Prism' into the Inherit structure of a StdStream

Examples:

>>> _Inherit # ()
Inherit

_UseHandle :: Prism' StdStream Handle Source #

A Prism' into the UseHandle structure's Handle for a StdStream

Examples:

>>> _UseHandle # System.stdin
UseHandle {handle: <stdin>}

_CreatePipe :: Prism' StdStream () Source #

A Prism' into the CreatePipe structure of a StdStream

Examples:

>>> _CreatePipe # ()
CreatePipe

_NoStream :: Prism' StdStream () Source #

A prism into the NoStream structure of a StdStream

Examples:

>>> _NoStream # ()
NoStream

Isos

_Handler :: Iso' ProcessHandler (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

An iso between the ProcessHandler data and its product representation

Traversals

arguments :: AsRaw a => Traversal' a [String] Source #

Traversal' into the arguments of a command

Examples:

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

Lenses

cmdspec_ :: Lens' CreateProcess CmdSpec Source #

Lens into the cmdspec entry of the CreateProcess record

cwd_ :: Lens' CreateProcess (Maybe FilePath) Source #

Lens into the cwd entry of the CreateProcess record

env_ :: Lens' CreateProcess (Maybe [(String, String)]) Source #

Lens into the env entry of the CreateProcess record

stdin_ :: Lens' CreateProcess StdStream Source #

Lens into the std_in entry of the CreateProcess record

stdout_ :: Lens' CreateProcess StdStream Source #

Lens into the std_out entry of the CreateProcess record

stderr_ :: Lens' CreateProcess StdStream Source #

Lens into the std_err entry of the CreateProcess record

closefds :: Lens' CreateProcess Bool Source #

Lens into the close_fds entry of the CreateProcess record

newsession :: Lens' CreateProcess Bool Source #

Lens into the new_session entry of the CreateProcess record

childgroup :: Lens' CreateProcess (Maybe CGid) Source #

Lens into the child_group entry of the CreateProcess record

childuser :: Lens' CreateProcess (Maybe CUid) Source #

Lens into the child_user entry of the CreateProcess record

hstdin :: Lens' ProcessHandler (Maybe Handle) Source #

A lens into the stdin handle if requested

hstdout :: Lens' ProcessHandler (Maybe Handle) Source #

A lens into the stdout handle if requested

hstderr :: Lens' ProcessHandler (Maybe Handle) Source #

A lens into the stderr handle if requested

hhandle :: Lens' ProcessHandler ProcessHandle Source #

A lens into the process handle

Classy Prisms

class AsRaw a where Source #

Classy prism into the raw command of a CmdSpec

Examples:

>>> f :: AsRaw a => a -> Maybe FilePath; f = preview (_Raw . _1)
>>> f $ _RawCommand # ("/bin/ls", ["ls -l"])
Just "/bin/ls"

Methods

_Raw :: Prism' a (FilePath, [String]) Source #

Instances

Instances details
AsRaw CmdSpec Source # 
Instance details

Defined in System.Process.Lens.CmdSpec

class AsShell a where Source #

Classy prism into the shell command of a CmdSpec

Examples:

>>> f :: AsShell a => a -> Maybe String; f = preview _Shell
>>> f $ _ShellCommand # "ls -l"
Just "ls -l"

Instances

Instances details
AsShell CmdSpec Source # 
Instance details

Defined in System.Process.Lens.CmdSpec

class AsInherit a where Source #

Class constraint proving a type has a prism into an Inherit structure. Any StdStream will have a prism into Inherit - it is just an overwrite to Inherit

Methods

_Inherits :: Prism' a () Source #

Instances

Instances details
AsInherit StdStream Source # 
Instance details

Defined in System.Process.Lens.StdStream

class AsUseHandle a where Source #

Class constraint proving a type has a prism into a Handle via a UseHandle structure.

Instances

Instances details
AsUseHandle StdStream Source # 
Instance details

Defined in System.Process.Lens.StdStream

class AsCreatePipe a where Source #

Class constraint proving a type has a prism into a Handle via a UseHandle structure. Any StdStream will have a prism into CreatePipe - it is just an overwrite to CreatePipe

Methods

_CreatesPipe :: Prism' a () Source #

Instances

Instances details
AsCreatePipe StdStream Source # 
Instance details

Defined in System.Process.Lens.StdStream

class AsNoStream a where Source #

Class constraint proving a type has a prism into a Handle via a UseHandle structure. Any StdStream will have a prism into NoStream - it is just an overwrite to NoStream.

Methods

_NoStreams :: Prism' a () Source #

Instances

Instances details
AsNoStream StdStream Source # 
Instance details

Defined in System.Process.Lens.StdStream

Classy Lenses

class HasStdin a where Source #

Classy lens for types with a stdin

class HasStdout a where Source #

Classy lens for types with a stdout

class HasStderr a where Source #

Classy lens for types with a stderr