Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
While the traditional monad examples - optionals and failure states - are already handled by those languages using different mechanisms, one area I noted a lot of struggle in that could be solved with monads (or something monad-like) was describing asynchronous tasks, such as retrieving data from an API. Another was update propagation, where a value would change in the database and something in the UI would need to be updated. We use ReactiveX to solve these problems, but it's really verbose at times and has some terminology that our newer devs would get hung up on. I think by taking some ideas from monads the syntax could become much clearer.
dotty-cps-async [rssh/dotty-cps-async ] with automatic coloring do something very similar in two steps. Automatic coloring defines implicit conversion F[A] => A as x => await(x)(m). The compiler inserts those awaits inside async blocks and then eliminates them later via cps-transform. Exists some limitations which we need to add for effect monads like IO (we don't want run effect twice and don't want to screw semantics of effects by extra memoizing). So, if your language has a possibility to implement effect monads, then you need a possibility to restrict using Flattenable.