Libretto is a declarative concurrency and stream processing library for Scala. Libretto adopts a highly concurrent programming model based on the principles of locality and linearity. Libretto programs are strongly typed with interaction interfaces represented via session types.
Being concurrent by design, it achieves seamless automatic concurrency restricted only by natural causal dependencies. Libretto programs are maximally concurrent by default; forcing sequentiality requires introducing explicit causal dependencies.
The principle of locality manifests itself in that interactions within Libretto programs are explicitly reflected in type signatures and can only occur with the immediate surroundings, i.e. there is no action at a distance such as through callbacks, indirection, resource capture, or side effects.
The principle of linearity states that each resource (value) in a Libretto program must be consumed exactly once. (This is inspired by the linear logic, wich is adopted by Libretto with a twist of interpreting the multiplicative conjunction in a concurrent fashion.) Linear resources in a type-safe program cannot be implicitly cloned or dropped, though some types can be marked as safe for duplication.
Libretto programs are interpreted as pure values, i.e. as computation descriptions/blueprints. Expressed in Scala code, a Libretto program first gets assembled into a description/blueprint of the program (in a form of an abstract syntax tree), which is then can be executed by an interpreter (which, in principle, can be a code generator).
Libretto is a declarative concurrency and stream processing library for Scala. Libretto adopts a highly concurrent programming model based on the principles of locality and linearity. Libretto programs are strongly typed with interaction interfaces represented via session types.
Being concurrent by design, it achieves seamless automatic concurrency restricted only by natural causal dependencies. Libretto programs are maximally concurrent by default; forcing sequentiality requires introducing explicit causal dependencies.
The principle of locality manifests itself in that interactions within Libretto programs are explicitly reflected in type signatures and can only occur with the immediate surroundings, i.e. there is no action at a distance such as through callbacks, indirection, resource capture, or side effects.
The principle of linearity states that each resource (value) in a Libretto program must be consumed exactly once. (This is inspired by the linear logic, wich is adopted by Libretto with a twist of interpreting the multiplicative conjunction in a concurrent fashion.) Linear resources in a type-safe program cannot be implicitly cloned or dropped, though some types can be marked as safe for duplication.
Libretto programs are interpreted as pure values, i.e. as computation descriptions/blueprints. Expressed in Scala code, a Libretto program first gets assembled into a description/blueprint of the program (in a form of an abstract syntax tree), which is then can be executed by an interpreter (which, in principle, can be a code generator).