commercialhaskell / rio

A standard library for Haskell
Other
838 stars 54 forks source link

Process Stdin example #181

Open locallycompact opened 5 years ago

locallycompact commented 5 years ago

Hi, I'm struggling to figure out how to do the equivalent of this in typed-process. Is there an example of how to use stdin with the different RIO.Process proc?

import RIO.Process
import qualified System.Process.Typed as S
let catConfig = setStdin (byteStringInput "foo")
                      $ S.proc "less" []
runProcess catConfig
snoyberg commented 5 years ago

Is this what you're looking for?

#!/usr/bin/env stack
-- stack --resolver lts-13.21 script
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
import RIO
import RIO.Process
import qualified System.Process.Typed as S

main :: IO ()
main =
  runSimpleApp $
  proc "less" [] $
  runProcess_ . setStdin (byteStringInput "foo")