module Network.IPFS.Process (runProc) where

import Network.IPFS.Prelude
import Network.IPFS.Process.Types

runProc ::
  ( MonadIO               m
  , MonadReader       cfg m
  , HasProcessContext cfg
  , HasLogFunc        cfg
  )
  => (ProcessConfig stdin stdout () -> m a)
  -> FilePath
  -> StreamIn  stdin
  -> StreamOut stdout
  -> [Opt]
  -> m a
runProc :: (ProcessConfig stdin stdout () -> m a)
-> FilePath
-> StreamIn stdin
-> StreamOut stdout
-> [FilePath]
-> m a
runProc ProcessConfig stdin stdout () -> m a
processor FilePath
binPath StreamIn stdin
inStream StreamOut stdout
outStream [FilePath]
opts =
  FilePath -> [FilePath] -> (ProcessConfig () () () -> m a) -> m a
forall env (m :: * -> *) a.
(HasProcessContext env, HasLogFunc env, MonadReader env m,
 MonadIO m, HasCallStack) =>
FilePath -> [FilePath] -> (ProcessConfig () () () -> m a) -> m a
proc FilePath
binPath [FilePath]
opts ((ProcessConfig () () () -> m a) -> m a)
-> (ProcessConfig () () () -> m a) -> m a
forall a b. (a -> b) -> a -> b
<| ProcessConfig stdin stdout () -> m a
processor
                  (ProcessConfig stdin stdout () -> m a)
-> (ProcessConfig () () () -> ProcessConfig stdin stdout ())
-> ProcessConfig () () ()
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StreamIn stdin
-> ProcessConfig () stdout () -> ProcessConfig stdin stdout ()
forall stdin stdin0 stdout stderr.
StreamSpec 'STInput stdin
-> ProcessConfig stdin0 stdout stderr
-> ProcessConfig stdin stdout stderr
setStdin  StreamIn stdin
inStream
                  (ProcessConfig () stdout () -> ProcessConfig stdin stdout ())
-> (ProcessConfig () () () -> ProcessConfig () stdout ())
-> ProcessConfig () () ()
-> ProcessConfig stdin stdout ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StreamOut stdout
-> ProcessConfig () () () -> ProcessConfig () stdout ()
forall stdout stdin stdout0 stderr.
StreamSpec 'STOutput stdout
-> ProcessConfig stdin stdout0 stderr
-> ProcessConfig stdin stdout stderr
setStdout StreamOut stdout
outStream