Monads Are Not About Sequencing (Lawful Monads In A Concurrent Setting)
Monads are often presented as a tool to describe computations as _sequences_ of steps (instructions, commands, effects, ...). Some even say that monads are the _essence_ of sequencing. On one hand, it's easy to see why monads are often associated with sequencing: In a strictly evaluated language like Scala, an expression must be fully evaluated before it can be mapped and/or flattened. In Haskell, an otherwise lazy language, the special IO monad enforces sequential evaluation of effects. In both Scala and Haskell, there is syntactic support (monad/for comprehensions) for the "sequence of steps" style. On the other hand, the mathematical definition of a monad says nothing about sequencing. Indeed, Haskell's laziness already allows—for the case of pure, deterministic computations—flatMapping without (fully) evaluating the input.
In this talk, Tomas will go further and show examples of lawful monads in a concurrent, effectful, and non-deterministic setting. Specifically, attendees will see that the monad laws do not necessitate sequential execution, ordering of effects, or even determinism. The examples will come from Libretto, a Scala DSL for declarative concurrency, where causal dependence is the only form of sequencing.