3 ms·
I heard that 5.0 does not include (user visible) effects (yet?). Is this planned for after 5.0? Anywhere I can learn more? Getting an effects system with hand
by the_duke 4y ago
I heard that 5.0 does not include (user visible) effects (yet?).
Is this planned for after 5.0? Anywhere I can learn more?
Getting an effects system with handlers in a (semi)large and mature language is a pretty big step.
The Koka language [1] has a brilliant implementation of algebraic effects. Sadly it's a research language that doesn't see much development.
[1] https://koka-lang.github.io/koka/doc/book.html#why-handlers https://koka-lang.github.io/koka/doc/book.html#why-handlers
- octachron 4y agoThe effect system is here, and it can already be used. However, the integration within the (surface) language and its type system is still a work in progress. Thus to explore the use of effects, you need to use the experimental Effect (https://github.com/ocaml/ocaml/blob/trunk/stdlib/effect.mli https://github.com/ocaml/ocaml/blob/trunk/stdlib/effect.mli) module which gives you access to low-level primitives for defining effects, installing an effect handler and resuming a continuation. The module will be considered as experimental in OCaml 5.0 and subsequent version of OCaml 5 will refine the integration within the language. The objective here was to decouple the multicore runtime work from the higher-level language design questions.
- kcsrk 4y agoI would also recommend reading the effect handlers tutorial in OCaml 5.0 manual: https://kcsrk.info/webman/manual/effects.html https://kcsrk.info/webman/manual/effects.html.
- momentoftop 4y agoIs there any plan to have effect types like in koka, where the effects that a function performs are visible in the type, and handling an effect eliminates it from the function's type?
- octachron 4y agoThe medium-term plan is indeed to have such a typed effect system. This one of the reason why the effect system is still considered to be experimental: we expect to see some breaking changes once effects become typed.
- pdimitar 4y agoThey plan to mainstream effects in OCaml 5.1 IIRC.
- avsm 4y agoEffects are included in OCaml 5, but considered experimental. This doesn't stop us from building libraries that take advantage of them internally, in order to provide really nice external interfaces. The best developed one is "eio", which uses effects (and io_uring on Linux) internally in order to provide a really high performance, direct-style IO library for OCaml. You can walk through some of the code here: https://github.com/ocaml-multicore/eio#getting-started https://github.com/ocaml-multicore/eio#getting-started Also a video talk about our experiences with using effects for writing parsers, from the OCaml Workshop last year. https://watch.ocaml.org/videos/watch/74ece0a8-380f-4e2a-bef5-c6bb9092be89 https://watch.ocaml.org/videos/watch/74ece0a8-380f-4e2a-bef5...