| Copyright | (c) 2024 Sayo contributors (c) The University of Glasgow 2004-2008 |
|---|---|
| License | MPL-2.0 (see the LICENSE file) AND BSD-3-Clause |
| Maintainer | ymdfield@outlook.jp |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Control.Monad.Hefty.Concurrent.Subprocess
Description
Effects for well-typed subprocess.
Synopsis
- data StdStream s where
- data CreateProcess p where
- CreateProcess :: {..} -> CreateProcess ('SubprocMode i o e lp ls)
- data Subprocess p :: Effect where
- WriteStdin :: ByteString -> Subprocess ('SubprocMode 'Piped o e lp 'Kill) f ()
- TryWriteStdin :: ByteString -> Subprocess ('SubprocMode 'Piped o e lp ls) f Bool
- ReadStdout :: Subprocess ('SubprocMode i 'Piped e lp ls) f ByteString
- ReadStderr :: Subprocess ('SubprocMode i o 'Piped lp ls) f ByteString
- PollSubproc :: Subprocess ('SubprocMode i o e lp 'Wait) f (Maybe ExitCode)
- data SubprocMode = SubprocMode StreamMode StreamMode StreamMode Lifecycle Lifecycle
- data StreamMode
- data Lifecycle
- type SubprocProvider es = Scoped Freer SubprocResult CreateProcess '[Subprocess] es
- data SubprocResult p a where
- RaceResult :: Either ExitCode a -> SubprocResult ('SubprocMode i o e 'Kill 'Kill) a
- SubprocResult :: ExitCode -> Maybe a -> SubprocResult ('SubprocMode i o e 'Wait 'Kill) a
- ScopeResult :: Maybe ExitCode -> a -> SubprocResult ('SubprocMode i o e 'Kill 'Wait) a
- SubprocScopeResult :: ExitCode -> a -> SubprocResult ('SubprocMode i o e 'Wait 'Wait) a
- data LifecycleMode t where
- data SubprocessLabel
- process :: FilePath -> [String] -> CreateProcess ('SubprocMode 'NoPipe 'NoPipe 'NoPipe 'Wait 'Wait)
- shell :: String -> CreateProcess ('SubprocMode 'NoPipe 'NoPipe 'NoPipe 'Wait 'Wait)
- runSubprocIO :: (UnliftIO :> es, Emb IO :> es) => Eff (SubprocProvider es ': es) a -> Eff es a
- toRawCreateProcess :: CreateProcess stdio -> CreateProcess
- hRead :: Handle -> IO ByteString
- chunkSize :: Int
- command :: CmdSpec -> CreateProcess ('SubprocMode 'NoPipe 'NoPipe 'NoPipe 'Wait 'Wait)
- commandWith :: CmdSpec -> StdStream i -> StdStream o -> StdStream e -> LifecycleMode lp -> LifecycleMode ls -> CreateProcess ('SubprocMode i o e lp ls)
- toRawStdStream :: StdStream pipe -> StdStream
- writeStdin :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f ()
- writeStdin' :: forall key (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f ()
- writeStdin'' :: forall tag (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode 'Piped o e lp 'Kill))) es) => ByteString -> f ()
- writeStdin'_ :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f ()
- tryWriteStdin :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool
- tryWriteStdin' :: forall key (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool
- tryWriteStdin'' :: forall tag (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode 'Piped o e lp ls))) es) => ByteString -> f Bool
- tryWriteStdin'_ :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool
- readStdout :: forall (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString
- readStdout' :: forall key (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString
- readStdout'' :: forall tag (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i 'Piped e lp ls))) es) => f ByteString
- readStdout'_ :: forall (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString
- readStderr :: forall (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString
- readStderr' :: forall key (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString
- readStderr'' :: forall tag (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i o 'Piped lp ls))) es) => f ByteString
- readStderr'_ :: forall (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString
- pollSubproc :: forall (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode)
- pollSubproc' :: forall key (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode)
- pollSubproc'' :: forall tag (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i o e lp 'Wait))) es) => f (Maybe ExitCode)
- pollSubproc'_ :: forall (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode)
- module Control.Monad.Hefty.Provider
- data CmdSpec
- type GroupID = CGid
- type UserID = CUid
- data Handle
- data ExitCode
- data ByteString
- hPut :: Handle -> ByteString -> IO ()
- hGet :: Handle -> Int -> IO ByteString
- hGetNonBlocking :: Handle -> Int -> IO ByteString
Documentation
data StdStream s where Source #
Constructors
| CreatePipe | |
| Inherit | |
| UseHandle | |
| NoStream | |
Fields
| |
data CreateProcess p where Source #
Constructors
| CreateProcess | |
Fields
| |
data Subprocess p :: Effect where Source #
Constructors
| WriteStdin :: ByteString -> Subprocess ('SubprocMode 'Piped o e lp 'Kill) f () | |
| TryWriteStdin :: ByteString -> Subprocess ('SubprocMode 'Piped o e lp ls) f Bool | |
| ReadStdout :: Subprocess ('SubprocMode i 'Piped e lp ls) f ByteString | |
| ReadStderr :: Subprocess ('SubprocMode i o 'Piped lp ls) f ByteString | |
| PollSubproc :: Subprocess ('SubprocMode i o e lp 'Wait) f (Maybe ExitCode) |
Instances
| FirstOrder (Subprocess p) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess | |
| HFunctor (Subprocess p) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess Methods hfmap :: (forall x. f x -> g x) -> Subprocess p f a -> Subprocess p g a # | |
| type LabelOf (Subprocess p) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess | |
| type OrderOf (Subprocess p) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess | |
data SubprocMode Source #
Constructors
| SubprocMode StreamMode StreamMode StreamMode Lifecycle Lifecycle |
data StreamMode Source #
type SubprocProvider es = Scoped Freer SubprocResult CreateProcess '[Subprocess] es Source #
data SubprocResult p a where Source #
Constructors
| RaceResult :: Either ExitCode a -> SubprocResult ('SubprocMode i o e 'Kill 'Kill) a | |
| SubprocResult :: ExitCode -> Maybe a -> SubprocResult ('SubprocMode i o e 'Wait 'Kill) a | |
| ScopeResult :: Maybe ExitCode -> a -> SubprocResult ('SubprocMode i o e 'Kill 'Wait) a | |
| SubprocScopeResult :: ExitCode -> a -> SubprocResult ('SubprocMode i o e 'Wait 'Wait) a |
Instances
| Show a => Show (SubprocResult p a) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess Methods showsPrec :: Int -> SubprocResult p a -> ShowS # show :: SubprocResult p a -> String # showList :: [SubprocResult p a] -> ShowS # | |
| Eq a => Eq (SubprocResult p a) Source # | |
Defined in Control.Monad.Hefty.Concurrent.Subprocess Methods (==) :: SubprocResult p a -> SubprocResult p a -> Bool # (/=) :: SubprocResult p a -> SubprocResult p a -> Bool # | |
data LifecycleMode t where Source #
Constructors
| KillMode :: LifecycleMode 'Kill | |
| WaitMode :: LifecycleMode 'Wait |
data SubprocessLabel Source #
process :: FilePath -> [String] -> CreateProcess ('SubprocMode 'NoPipe 'NoPipe 'NoPipe 'Wait 'Wait) Source #
runSubprocIO :: (UnliftIO :> es, Emb IO :> es) => Eff (SubprocProvider es ': es) a -> Eff es a Source #
toRawCreateProcess :: CreateProcess stdio -> CreateProcess Source #
commandWith :: CmdSpec -> StdStream i -> StdStream o -> StdStream e -> LifecycleMode lp -> LifecycleMode ls -> CreateProcess ('SubprocMode i o e lp ls) Source #
toRawStdStream :: StdStream pipe -> StdStream Source #
writeStdin :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f () Source #
writeStdin' :: forall key (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f () Source #
writeStdin'' :: forall tag (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode 'Piped o e lp 'Kill))) es) => ByteString -> f () Source #
writeStdin'_ :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode 'Piped o e lp 'Kill)) es) => ByteString -> f () Source #
tryWriteStdin :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool Source #
tryWriteStdin' :: forall key (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool Source #
tryWriteStdin'' :: forall tag (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode 'Piped o e lp ls))) es) => ByteString -> f Bool Source #
tryWriteStdin'_ :: forall (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode 'Piped o e lp ls)) es) => ByteString -> f Bool Source #
readStdout :: forall (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString Source #
readStdout' :: forall key (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString Source #
readStdout'' :: forall tag (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i 'Piped e lp ls))) es) => f ByteString Source #
readStdout'_ :: forall (i :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i 'Piped e lp ls)) es) => f ByteString Source #
readStderr :: forall (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString Source #
readStderr' :: forall key (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString Source #
readStderr'' :: forall tag (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i o 'Piped lp ls))) es) => f ByteString Source #
readStderr'_ :: forall (i :: StreamMode) (o :: StreamMode) (lp :: Lifecycle) (ls :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i o 'Piped lp ls)) es) => f ByteString Source #
pollSubproc :: forall (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode) Source #
pollSubproc' :: forall key (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, Has key (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode) Source #
pollSubproc'' :: forall tag (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, (:>) (Tagged tag (Subprocess ('SubprocMode i o e lp 'Wait))) es) => f (Maybe ExitCode) Source #
pollSubproc'_ :: forall (i :: StreamMode) (o :: StreamMode) (e :: StreamMode) (lp :: Lifecycle) f es ff c. (Free c ff, f ~ Eff ff es, In (Subprocess ('SubprocMode i o e lp 'Wait)) es) => f (Maybe ExitCode) Source #
module Control.Monad.Hefty.Provider
Constructors
| ShellCommand String | A command line to execute using the shell |
| RawCommand FilePath [String] | The name of an executable with a list of arguments The
Windows does not have a mechanism for passing multiple arguments.
When using |
Instances
| IsString CmdSpec | construct a Since: process-1.2.1.0 |
Defined in System.Process.Common Methods fromString :: String -> CmdSpec # | |
| Show CmdSpec | |
| Eq CmdSpec | |
Haskell defines operations to read and write characters from and to files,
represented by values of type Handle. Each value of this type is a
handle: a record used by the Haskell run-time system to manage I/O
with file system objects. A handle has at least the following properties:
- whether it manages input or output or both;
- whether it is open, closed or semi-closed;
- whether the object is seekable;
- whether buffering is disabled, or enabled on a line or block basis;
- a buffer (whose length may be zero).
Most handles will also have a current I/O position indicating where the next
input or output operation will occur. A handle is readable if it
manages only input or both input and output; likewise, it is writable if
it manages only output or both input and output. A handle is open when
first allocated.
Once it is closed it can no longer be used for either input or output,
though an implementation cannot re-use its storage while references
remain to it. Handles are in the Show and Eq classes. The string
produced by showing a handle is system dependent; it should include
enough information to identify the handle for debugging. A handle is
equal according to == only to itself; no attempt
is made to compare the internal state of different handles for equality.
Instances
Defines the exit codes that a program can return.
Instances
| Exception ExitCode | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods toException :: ExitCode -> SomeException # fromException :: SomeException -> Maybe ExitCode # displayException :: ExitCode -> String # | |
| Generic ExitCode | |
| Read ExitCode | |
| Show ExitCode | |
| NFData ExitCode | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
| Eq ExitCode | |
| Ord ExitCode | |
Defined in GHC.IO.Exception | |
| type Rep ExitCode | |
Defined in GHC.IO.Exception type Rep ExitCode = D1 ('MetaData "ExitCode" "GHC.IO.Exception" "base" 'False) (C1 ('MetaCons "ExitSuccess" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExitFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) | |
data ByteString #
A space-efficient representation of a Word8 vector, supporting many
efficient operations.
A ByteString contains 8-bit bytes, or by using the operations from
Data.ByteString.Char8 it can be interpreted as containing 8-bit
characters.
Instances
hPut :: Handle -> ByteString -> IO () #
Outputs a ByteString to the specified Handle.
hGet :: Handle -> Int -> IO ByteString #
Read a ByteString directly from the specified Handle. This
is far more efficient than reading the characters into a String
and then using pack. First argument is the Handle to read from,
and the second is the number of bytes to read. It returns the bytes
read, up to n, or empty if EOF has been reached.
hGet is implemented in terms of hGetBuf.
If the handle is a pipe or socket, and the writing end
is closed, hGet will behave as if EOF was reached.
hGetNonBlocking :: Handle -> Int -> IO ByteString #
hGetNonBlocking is similar to hGet, except that it will never block
waiting for data to become available, instead it returns only whatever data
is available. If there is no data available to be read, hGetNonBlocking
returns empty.
Note: on Windows and with Haskell implementation other than GHC, this
function does not work correctly; it behaves identically to hGet.