module System.Process.Corecursive
( runCorecursiveApp
, callback
, readCallback
, App
, Self
, app
) where
import Control.Monad (void)
import Control.Monad.IO.Class (liftIO, MonadIO)
import System.Environment (getArgs, getExecutablePath)
import System.Process (callProcess, readProcess)
import System.Process.Corecursive.Base (runApp, app, App, Self(..))
runCorecursiveApp :: MonadIO m => App m [String] arg FilePath () -> m ()
runCorecursiveApp =
runApp (liftIO getExecutablePath) (liftIO getArgs)
callback :: MonadIO m => Self m [String] arg FilePath -> arg -> m ()
callback self a = do
exe <- executable self
args <- unparse self $ a
liftIO $ callProcess exe args
readCallback :: MonadIO m => Self m [String] arg FilePath -> arg -> m String
readCallback self a = do
exe <- executable self
args <- unparse self $ a
liftIO $ readProcess exe args ""