HasChor-0.1.0.1: Functional choreographic programming in Haskell
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.

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.

BCast :: Show a => a -> NetworkSig m ()

Broadcasting.

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.

broadcast :: Show a => a -> Network m () Source #

Broadcast a message to all participants.

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 #