Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Types for building (co-)recursive system programs.
The tools in this module allow to define the call-site and the main entry point of a (co-)recursive program.
However, this module does not define callback
usages so that implementers
are free to chose the mechanism they want to:
- start the recursive program
- retrieve a return-value (if the recursive program ever returns)
Synopsis
- data App t msg arg inst ret = App {
- parseArgs :: msg -> t arg
- unparseArgs :: arg -> t msg
- corecursiveProgram :: Self t msg arg inst -> arg -> t ret
- app :: (msg -> m arg) -> (arg -> m msg) -> (Self m msg arg inst -> arg -> m ret) -> App m msg arg inst ret
- runApp :: Monad m => m inst -> m msg -> App m msg arg inst ret -> m ret
- data Self t msg arg inst = Self {
- executable :: t inst
- unparse :: arg -> t msg
Documentation
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
.
App | |
|
:: (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.
:: Monad m | |
=> m inst | An action to locate the self instance of an applictaion.
This action is run exactly once and the result is stored in |
-> m msg | An action to retrieve the message to start the application with. This action is run exactly once, the result is then parsed and discarded. |
-> App m msg arg inst ret | The |
-> m ret |
Typical function to run an App
with simplifying assumptions:
- locate the Self instance once for the rest of the program
- reads the arguments once
- starts the actual program
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
.
Self | |
|