MultiChor-1.1.0.0: Type-safe and efficient choreographies with location-set polymorphism.
Safe HaskellSafe-Inferred
LanguageGHC2021

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

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

run :: m a -> Network m a Source #

Perform a local computation.

send :: Show a => a -> [LocTm] -> Network m () Source #

Send a message to a receiver.

recv :: Read a => LocTm -> Network m a Source #

Receive a message from a sender.

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.

Methods

runNetwork :: MonadIO m => c -> LocTm -> Network m a -> m a Source #

Instances

Instances details
Backend HttpConfig Source # 
Instance details

Defined in Choreography.Network.Http

Methods

runNetwork :: MonadIO m => HttpConfig -> LocTm -> Network m a -> m a Source #

Backend LocalConfig Source # 
Instance details

Defined in Choreography.Network.Local

Methods

runNetwork :: MonadIO m => LocalConfig -> LocTm -> Network m a -> m a Source #