Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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.
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
- BCast :: Show a => a -> NetworkSig m ()
- 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
- broadcast :: Show a => a -> Network m ()
- 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.
Run :: m a -> NetworkSig m a | Local computation. |
Send :: Show a => a -> LocTm -> NetworkSig m () | Sending. |
Recv :: Read a => LocTm -> NetworkSig m a | Receiving. |
BCast :: Show a => a -> NetworkSig m () | Broadcasting. |
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 runNetwork :: MonadIO m => HttpConfig -> LocTm -> Network m a -> m a Source # | |
Backend LocalConfig Source # | |
Defined in Choreography.Network.Local runNetwork :: MonadIO m => LocalConfig -> LocTm -> Network m a -> m a Source # |