Future of OCaml
Some interesting news/developments coming up in OCaml’s future:
Interesting Pull Requests
- Array data types: Right now, OCaml has multiple array types (string, float array, array) that are treated differently. This PR is an attempt to combine these into one type, while allowing for future optimization.
- Quoted Extensions: Currently, a PPX extension that embeds another language must use a string type. This mechanism would automatically embed whatever it finds into a string.
- Best fit allocator: See explanation.
- Towards a new closure representation
- Creating a syntax for using constructors as functions
Currently, OCaml has a global runtime lock,
with support for green threads (concurrency) via
The plan is to allow OCaml to run in parallel threads (which are termed
while also allowing for native green thread support via algebraic effects.
- Multicore: what’s coming in 2021 presentation
- Monthly updates
- Paper on retrofitting a parallel GC into OCaml
- The multicore OCaml github repo and its wiki.
- The multicore roadmap.
- ICFP Presentation on advanced lock-free programming in multicore OCaml
- Discuss post on recent past and future of integrating multicore
- Update on status of multicore
- Adjusting the stdlib for multicore
Typed Algebraic Effects
Part of the plan for multicore OCaml is to include non-monadic green threading into the runtime. In order to allow for this, algebraic effects are being added to the language. These are similar to exceptions but with a bookmark to the current position of the execution (aka continutation) added to each “exception” (aka effect) thrown, so one has the option to continue execution after handling the effect.
Initially, this was going to exist outside of the type system. However, this introduces many issues, and we’d much rather have it be typed and handled by the type system. Extending OCaml’s type system with algebraic effects would make it similar to Haskell’s, but without requiring monads for effects.
See the tutorial above for an introduction to (untyped) algebraic effects. Work on typed effects is ongoing here.
- A great explanation of algebraic effects can be found here.
- Presentation on algebraic effects at ICFP
- Presentation on typed effects in OCaml
- Complete bibilography of literature on effects
A type-based dispatch similar to Haskell’s typeclasses.
See a video demonstration here. As this paper clarifies, creating typeclasses in OCaml is difficult due to its adherence to type abstraction. Put simply, you can have functors or type classes, but not both, and OCaml already has functors. While the community eagerly awaits this solution, its implementation unfortunately appears to be years away.