corecursive-main-0.1.0.0: Write your main like it can call itself back.

Safe HaskellSafe
LanguageHaskell2010

System.Process.Corecursive

Contents

Description

A module to facilitate and demonstrate a programming pattern where application instances for a system is (co-)recursive.

Synopsis

Documentation

runCorecursiveApp :: MonadIO m => App m [String] arg FilePath () -> m () Source #

Run function for an App which arguments are read from the command line using getArgs and for which the binary is discovered from getExecutablePath.

callback :: MonadIO m => Self m [String] arg FilePath -> arg -> m () Source #

Callback running the Self executable locally and waiting until completion using callProcess.

readCallback :: MonadIO m => Self m [String] arg FilePath -> arg -> m String Source #

Callback running the Self executable locally and waiting until completion using readProcess.

re-exported for convenience

data App t msg arg inst ret Source #

A datatype wrapping everything needed to make a (co-)recursive main function.

Application authors may find this type useful because it has a Functor instance, allowing to adapt the result of a computation.

See app.

Instances
Functor t => Functor (App t msg arg inst) Source # 
Instance details

Defined in System.Process.Corecursive.Base

Methods

fmap :: (a -> b) -> App t msg arg inst a -> App t msg arg inst b #

(<$) :: a -> App t msg arg inst b -> App t msg arg inst a #

data Self t msg arg inst Source #

A datatype representing an instance of the (co-)recursive program.

A reason why the records in this type are separate from App is that a calling program may need to execute a fair amount of progress before knowing the right executable (e.g., in the case of a remote invocation). Also, sometimes one may want to adapt Self.

Instances
Functor t => Functor (Self t msg arg) Source # 
Instance details

Defined in System.Process.Corecursive.Base

Methods

fmap :: (a -> b) -> Self t msg arg a -> Self t msg arg b #

(<$) :: a -> Self t msg arg b -> Self t msg arg a #

app Source #

Arguments

:: (msg -> m arg)

Function parsing argument from a serialized message.

-> (arg -> m msg)

Function un-parsing an argument into a serialized message.

-> (Self m msg arg inst -> arg -> m ret)

Actual program to run from a specification.

-> App m msg arg inst ret 

Constructor for an App.