OCaml 5 Effects syntax

I’ve been experimenting with OCaml 5 zeroth release and the effects system. I also found this nice tutorial and tried following along; however, the compiler gives me a syntax error if I try defining effects like this:

effect Eff : string -> int

(Also trying to “catch” the effect in a try with seems to not be valid either)

I was wondering, is this syntax still supported in the zeroth release or am I supposed to only use the Effects.match_with?

The effect system is an experimental feature of OCaml 5.0 that is not part of the surface language and it is only accessible through the low-level primitive exposed in the Effect module. There is a preview of the 5.0 manual tutorial for effect available here OCaml - Language extensions that covers those primitives in more detail. The main idea here is that the design of the effect system will be refined in the subsequent release of the language, in order to have the time to explore the design space for the typed effect system.

5 Likes