libretto.examples

Type members

Classlikes

object CoffeeMachine extends StarterApp
object Echo extends StarterApp

Reads lines from standard input and prints them to standard output.

Reads lines from standard input and prints them to standard output.

object Fibonacci extends StarterApp
object HelloWorld extends StarterAppScala[String]
object PingPong extends StarterApp

This example implements interaction between two parties, Alice and Bob, in which

This example implements interaction between two parties, Alice and Bob, in which

  • Alice sends "ping" to Bob,
  • Bob sends "pong" back to Alice,
  • Alice sends Done to Bob,

in this order, after which no more interaction between the two takes place.

This example demonstrates:

  • A simple protocol between two parties.
  • Linearity: obligation to consume every input exactly once and fulfill every demand exactly once. Linearity is key to ensuring adherence to a protocol.
  • Inverting the flow of values from left-to-right to right-to-left and vice versa.
object PingPongN extends StarterApp

This example implements interaction between two parties, Alice and Bob, in which

This example implements interaction between two parties, Alice and Bob, in which

  • when it's Alice's turn, she can choose to send "ping" to Bob or to quit;
  • when it's Bob's turn, he can choose to send "pong" back to Alice, or to quit;
  • interaction continues until one of the parties quits.

This is an extension of the PingPong example to multiple rounds of ping-pong. It further demonstrates:

  • The choice operators |+| and |+|.
  • Recursive protocol type.
object PoolingMicroscopes extends StarterApp

N scientists sharing M microscopes (N > M).

N scientists sharing M microscopes (N > M).

This examples demonstrates:

  • concurrency (scientists operate concurrently)
  • sequencing (each scientist performs experiments sequentially, at most one at a time)
  • resource sharing via pooling (the limited number of microscopes is made available throught a pool)