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.
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 devThis command exposes the terminal of the container. To run the toolchain (e.g. show the helptext):
dev@dev:~$ dottygen --helpdottygencontains the source code of our code generator, written in Python, which generates Effpi-typed Scala code for implementing the provided multiparty protocol.protocolscontains various Scribble protocol descriptions, including those used in the case studies.case_studiescontains 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.scriptscontains various convenient scripts to run the toolchain and build the case studies.setupcontains scripts to set up the Docker container.effpi_sandboxis the default output directory of the tool, which is a sandbox environment set up for the Scala3 Compiler.
Refer to the helptext for detailed information:
$ dottygen --helpWe illustrate how to use our toolchain to generate Session+ Effpi-typed program:
The following command reads as follows:
$ dottygen ~/protocols/TravelAgency.scr TravelAgency-
Generate APIs for each role of the
TravelAgencyprotocol specified in~/protocols/TravelAgency.scr; -
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'To run the end-to-end tests:
# Run from any directory
$ run_testsThe 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.
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 BankMicroserviceTo run the case study NoughtsAndCrosses:
$ sbt 'case_studies/runMain sandbox.Bank.Main'and visit http://localhost:8080.