Write a Blog >>
Scala 2017
Sun 22 - Mon 23 October 2017 Vancouver, Canada
co-located with SPLASH 2017
Sun 22 Oct 2017 16:37 - 17:00 at Regency C - Open-source & Student Talks Chair(s): Guido Salvaneschi

Flatline is a library in Scala which provides a simple EDSL to implement extensible and modular command line argument parsers and simple REPLs in a declarative and typesafe way. I will talk about the design decisions for the flatline library.

The modularity flatline can provide to applications is impressive. It is so easy to setup an application to expose a complete new set of commands to the command line. If the Play framework implemented the CLI argument parser with flatline, Play could easily let applications provide custom CLI commands or even whole subcommand branches which are then used to, for example, mockup the UI for a demo version without infrastructure or automatic UI tests.

Other CLI libraries have either relaxed syntax and semantics (as seen in scopt and scallop), use reflection (see JewelCLI) or use meta programming (see sbt’s REPL). Dependent types give us independence of runtime and platform features to ensure typesafety and do not require AST manipulation. The more restrictive syntax and semantics allow for more freedom in choice of the parsing strategy.

The EDSL is implemented with object algebras which benefits the library in multilple ways. First, it helps us to decouple library interface and implementation. Second, it tightens semantics and reduces the amount of (bad and good) programs that compile. It is now safe to assume that modules written in flatline are free of unpredictable side-effect and can be worry free composed. Besides that, the library interface itself is extensible and can be enriched with new features.

The design choices made for flatline allow easier maintenance of the library itself and applications written in flatline. The requirement for platform specific code erases and interface and implementation are decoupled. This makes our applications more portable, maintainable, and extensible in the long term. Flatline shows exemplary how important the design of a library interface is.

Sun 22 Oct

Displayed time zone: Tijuana, Baja California change