ocaml-multicore/effects-examples

Examples to illustrate the use of algebraic effects in Multicore OCaml

454

stars

182

commits

OCaml

primary language

Mar 20, 2026

updated

README

OCaml effects examples

Build Status

Examples to illustrate the use of algebraic effects in OCaml. See

Examples

The original implementation of Multicore OCaml allowed a user to Obj.clone_continuation. This has been removed, the examples that used this are in the multishot directory. See this conversation about the removal of this feature. They now use the ocaml-multicont library.

Running the examples

To run the examples with OCaml, be sure to install Opam with these instructions. These examples use the new effect syntax introduced with OCaml 5.3 and onwards. If you wish to see the examples which used the underlying effect functions directly, please checkout the 5.1.1 tag of this repository instead.

# After cloning this repository, create a 5.4.1 switch
opam update
opam switch create 5.4.1
opam install . --deps-only

Running make will build all of the examples. If you want to run a single executable that is built with dune you can run:

$ dune exec -- ./<executable_name>.exe

External examples

These are other examples that utilise OCaml effect handlers that are not in this repo:

Citation

If you are citing this work in an academic paper, please cite the PLDI 2021 paper "Retrofitting Effect Handlers onto OCaml": https://dl.acm.org/doi/10.1145/3453483.3454039.

Contributors

kayceesrk

118 commits

dhil

18 commits

patricoferris

12 commits

avsm

9 commits

ocaml-multicore/effects-examples

Examples to illustrate the use of algebraic effects in Multicore OCaml

454

stars

182

commits

OCaml

primary language

Mar 20, 2026

updated

README

OCaml effects examples

Build Status

Examples to illustrate the use of algebraic effects in OCaml. See

Examples

The original implementation of Multicore OCaml allowed a user to Obj.clone_continuation. This has been removed, the examples that used this are in the multishot directory. See this conversation about the removal of this feature. They now use the ocaml-multicont library.

Running the examples

To run the examples with OCaml, be sure to install Opam with these instructions. These examples use the new effect syntax introduced with OCaml 5.3 and onwards. If you wish to see the examples which used the underlying effect functions directly, please checkout the 5.1.1 tag of this repository instead.

# After cloning this repository, create a 5.4.1 switch
opam update
opam switch create 5.4.1
opam install . --deps-only

Running make will build all of the examples. If you want to run a single executable that is built with dune you can run:

$ dune exec -- ./<executable_name>.exe

External examples

These are other examples that utilise OCaml effect handlers that are not in this repo:

Citation

If you are citing this work in an academic paper, please cite the PLDI 2021 paper "Retrofitting Effect Handlers onto OCaml": https://dl.acm.org/doi/10.1145/3453483.3454039.

Contributors

kayceesrk

118 commits

dhil

18 commits

patricoferris

12 commits

avsm

9 commits

Languages

OCaml

94.8%

Haskell

2.2%

Makefile

1.9%