Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jarredlim/DottyGenerator

Repository files navigation

Multiparty Session Types in Scala/Dotty

A mono-repo for a Effpi + session type API code generation toolchain for Scala program.

This project was originally built for the author's at Imperial College London.

  1. Getting started

  2. User guide


1️⃣ Getting started

Docker workflow (recommended)

The following steps assume a Unix environment with Docker properly installed. Other platforms supported by Docker may find a similar way to import the Docker image.

$ git clone --recursive https://github.com/jarredlim/DottyGenerator.git
$ cd DottyGenerator
$ docker-compose run --service-ports dev

This command exposes the terminal of the container. To run the toolchain (e.g. show the helptext):

dev@dev:~$ dottygen --help

Repository Layout

  • dottygen contains the source code of our code generator, written in Python, which generates Effpi-typed Scala code for implementing the provided multiparty protocol.
  • protocols contains various Scribble protocol descriptions, including those used in the case studies.
  • case_studies contains 2 case studies of implementing Session+Effpi-typed Scala applications with our toolchain, namely Two Buyers with Negotiation and Bank with Microservices.
  • benchmarkscontains the code to generate performance benchmarks.
  • scripts contains various convenient scripts to run the toolchain and build the case studies.
  • setup contains scripts to set up the Docker container.
  • effpi_sandbox is the default output directory of the tool, which is a sandbox environment set up for the Scala3 Compiler.

2️⃣ User guide

Using code generation toolchain

Refer to the helptext for detailed information:

$ dottygen --help

We illustrate how to use our toolchain to generate Session+ Effpi-typed program:

Generating Program from Protocol

The following command reads as follows:

$ dottygen ~/protocols/TravelAgency.scr TravelAgency
  1. Generate APIs for each role of the TravelAgency protocol specified in ~/protocols/TravelAgency.scr;

  2. Output the generated program under the path ~/effpi_sandbox/src/main/scala

Execute the generated program with

$ sbt 'tests/runMain effpi_sandbox.[protocol name].Main'

Running tests

To run the end-to-end tests:

# Run from any directory
$ run_tests

The end-to-end tests verify that

  • The toolchain correctly parses the Scribble protocol specification files, and,
  • The toolchain correctly generates Effpi+Session-typed Scala programs, and,
  • The generated programs can be type-checked by the TypeScript Compiler successfully.

The protocol specification files, describing the multiparty communication, are located in ~/dottygen/tests/system/examples. The generated programs are saved under ~/effpi_sandbox and are deleted when the test finishes.

Running case studies

Run the following to install dependencies for any pre-existing case studies:

$ setup_case-studies [case study name]

We include two case studies of realistic web applications implemented using our tool.

For example, to generate the program for the case study Bank with Microservices:

# Run from any directory
$ seup_case-studies BankMicroservice

To run the case study NoughtsAndCrosses:

$ sbt 'case_studies/runMain sandbox.Bank.Main'

and visit http://localhost:8080.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages