Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more process functions and a motivating example #73

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/30-process-handlers.hell
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
main = do
Temp.withSystemTempFile "example" \filePath handle -> do
Text.putStrLn $ Text.concat ["Created temp file ", filePath]
let proc = Process.setStdout (Process.useHandleClose handle) $
Process.proc "ls" ["-al"]
Process.runProcess_ proc
contents <- Text.readFile filePath
Text.putStrLn contents
8 changes: 6 additions & 2 deletions src/Hell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,8 +1243,7 @@ supportedLits =
-- Process
("Process.proc", lit' $ \n xs -> proc (Text.unpack n) (map Text.unpack xs)),
("Process.setEnv", lit' $ Process.setEnv @() @() @() . map (bimap Text.unpack Text.unpack)),
("Process.runProcess", lit' $ runProcess @IO @() @() @()),
("Process.runProcess_", lit' $ runProcess_ @IO @() @() @()),

-- Exit
("Exit.ExitSuccess", lit' Exit.ExitSuccess),
("Exit.ExitFailure", lit' Exit.ExitFailure),
Expand Down Expand Up @@ -1580,6 +1579,11 @@ polyLits =
-- Temp
"Temp.withSystemTempFile" temp_withSystemTempFile :: forall a. Text -> (Text -> IO.Handle -> IO a) -> IO a
"Temp.withSystemTempDirectory" temp_withSystemTempDirectory :: forall a. Text -> (Text -> IO a) -> IO a
-- Process
"Process.runProcess" runProcess :: forall a b c. ProcessConfig a b c -> IO ExitCode
"Process.runProcess_" runProcess_ :: forall a b c. ProcessConfig a b c -> IO ()
"Process.setStdout" setStdout :: forall stdin stdout stdout' stderr. StreamSpec 'STOutput stdout' -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout' stderr
"Process.useHandleClose" useHandleClose :: forall (a :: StreamType). IO.Handle -> StreamSpec a ()
|]
)

Expand Down
Loading