heftia/heftia-effects/Example/Subprocess/Main.hs
2024-11-03 18:52:57 +09:00

26 lines
574 B
Haskell

-- SPDX-License-Identifier: MPL-2.0
module Main where
import Control.Monad.Hefty (liftIO, (&))
import Control.Monad.Hefty.Concurrent.Subprocess (
CreateProcess (stdout),
StdStream (CreatePipe),
SubprocResult,
readStdout'',
runSubprocIO,
scope,
shell,
)
import Control.Monad.Hefty.Unlift (runUnliftIO)
main :: IO ()
main = runUnliftIO . runSubprocIO $ do
r <- scope @"echo" @SubprocResult (shell "echo a b c") {stdout = CreatePipe} \_ -> do
readStdout'' @"echo"
print r & liftIO
{-
SubprocScopeResult ExitSuccess "a b c\n"
-}