Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Choreography.Network
Description
This module defines the Network
monad, which represents programs run on
individual nodes in a distributed system with explicit sends and receives.
To run a Network
program, we provide a runNetwork
function that supports
multiple message transport backends.
Two such backends are provided in Choreography.Network.Http and Choreography.Network.Local,
and there should be enough tools here for you to write more as needed.
Synopsis
- data NetworkSig m a where
- Run :: m a -> NetworkSig m a
- Send :: Show a => a -> [LocTm] -> NetworkSig m ()
- Recv :: Read a => LocTm -> NetworkSig m a
- type Network m = Freer (NetworkSig m)
- run :: m a -> Network m a
- send :: Show a => a -> [LocTm] -> Network m ()
- recv :: Read a => LocTm -> Network m a
- class Backend c where
- runNetwork :: MonadIO m => c -> LocTm -> Network m a -> m a
The Network monad
data NetworkSig m a where Source #
Effect signature for the Network
monad.
Constructors
Run :: m a -> NetworkSig m a | Local computation. |
Send :: Show a => a -> [LocTm] -> NetworkSig m () | Sending. |
Recv :: Read a => LocTm -> NetworkSig m a | Receiving. |
type Network m = Freer (NetworkSig m) Source #
Monad that represents network programs.
Network operations
Message transport backends
class Backend c where Source #
A message transport backend defines a configuration of type c
that
carries necessary bookkeeping information, then defines c
as an instance
of Backend
and provides a runNetwork
function.
Instances
Backend HttpConfig Source # | |
Defined in Choreography.Network.Http Methods runNetwork :: MonadIO m => HttpConfig -> LocTm -> Network m a -> m a Source # | |
Backend LocalConfig Source # | |
Defined in Choreography.Network.Local Methods runNetwork :: MonadIO m => LocalConfig -> LocTm -> Network m a -> m a Source # |