A few years ago when OCaml 5.0 landed with effects, there was a lot of discussion about making them typed in a way that prevents unhandled-effect runtime errors. Back then, there seemed to be an impression that typed effects were coming soon and they would be a necessary improvement. If you look back at old discussions, there’s a lot of advice saying to avoid using effects until the typed version arrives.
In the years since then, a lot of new features have come to OCaml, but I haven’t heard any news about typed effects. At the same time, people don’t seem to have reservations about using untyped effects anymore (or if they do, they don’t express them as publicly as they used to).
I’m curious: is this still on the timeline somewhere? I’m also curious if there’s still a demand for typed effects now, since untyped effects seem to have gained traction on their own.
Was there really an impression that typed effects were ‘coming soon’? My understanding was always that they were mostly conceptual at that point and a lot of theoretical and academic work needed to be done for them to even reached POC stage. I don’t think anyone has so much as shown a demo?
Back when effects were first getting released, there was a lot of discussion where people said things like “wait to use effects until they’re typed,” “we don’t want to add a syntax for effects until they’re typed,” or “let’s wait for typed effects before we add features X Y and Z.” I don’t want to go dig up all of the exact quotes, but people then seemed to believe that typed effects were on the timeline. They certainly gave me the impression that typed effects were actively being worked on.
I’m fairly sure the messaging was more along the lines of ‘don’t use untyped effects directly in application code yet, use them indirectly via libraries like Eio that wrap their functionality’.
Maybe there was a communication gap that made people think that meant typed effects were on the way, but the way I see it, there are a lot of design issues to solve before that, not the least of which is that it would basically be ’checked exceptions’, and everybody hates those…
The only thing I would add to this discussion is that Jane Street is making progress on the related front of statically guaranteeing that effects are handled in OxCaml with modes. It’s not fully typed effects, but it is an interesting way of making effects much more usable in application code. They even have a library codifying the concept: GitHub - janestreet/handled_effect: Typed effects API for OxCaml · GitHub (where they call it “typed effects,” but I’m not sure that’s what most people would mean by it).
A couple years ago I tried to get people to work on typed effects specifically for OCaml, but I failed to gather steam and actually do it (apologies!). There are plenty of people in academia working on type systems for effects, but most of it is not directly applicable to OCaml. I don’t know of active projects to retrofit effects into OCaml (there is comparatively a lot more on effect via capability control in Scala, and also some energy going into Koka, Effekt, Lexa etc.), except of course for the work on modes in OxCaml.
I feel bad about this because I think that typed effects would be much more usable than untyped effects, but this is not a consensus position (some people say that because effects are more pervasives than exceptions in libraries that use them, we catch mistakes earlier in normal testing). And no one believes that retrofitting an effect system into OCaml would be easy.
Hmm… as a semi-official position, this is disappointing. I also thought untyped effects were sold as a springboard to typed effects somewhere down the line, but it seems like that’s not in the works. That makes me want to avoid effects even more outside of concurrency. In a world where every library utilizes its own effects all over the place, OCaml becomes a far less safe language.
I appreciate the insight. It’s slightly disappointing that the work doesn’t seem to be going anywhere (for OCaml at least) since typed effects always seemed like an intriguing feature to me.
I’m personally happy using the untyped effects we have now, but sometimes wonder about what effects could become in the future.