heftia/heftia-effects/Example/Subprocess/Main.hs

26 lines
574 B
Haskell
Raw Normal View History

2024-11-03 12:41:51 +03:00
-- 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
2024-11-03 12:52:57 +03:00
r <- scope @"echo" @SubprocResult (shell "echo a b c") {stdout = CreatePipe} \_ -> do
readStdout'' @"echo"
2024-11-03 12:41:51 +03:00
print r & liftIO
{-
SubprocScopeResult ExitSuccess "a b c\n"
-}