An example project to show multiple Scala 3 (Dotty) features in a simple web application.
This project was created to try Scala 3 in a working program, find possible use cases and meet problems that may appear while creating a "real" web application.
If you have any comments or ideas related to the project please add them to GitHub Discussions of the project - Dotty is a new thing so every input can help in learning it.
The program is a simple web application that allows the user to obtain information about celestial bodies. It is simplified not to hide Scala 3 features in a bloated code structure. Only GET HTTP method is used, the responses are encoded into JSON.
The project uses the following Scala 3 features:
- Givens in multiple cases.
- New enums, parametrized and not, also used to define ADT.
- Extension methods.
- Opaque type aliases to keep domain values.
- Automatic type class derivation for response JSON encoding.
- Implicit conversions in a new Scala 3 way.
- AkkaHttp as a Scala 2 integration example.
- Scala 3 test framework usage with givens profits.
- The new way to define program entry point with @main annotation.
- Union and intersection types.
This is a normal sbt project, you can compile code with sbt compile
and run it
with sbt "run <port number>"
. The unit tests are executed with sbt test
.
The program accepts one argument - the port to listen. On start example requests are displayed.
For more information on the Dotty and features used in the project, please visit: dotty-reference.