Examples to illustrate the use of algebraic effects in OCaml. See
- Effective Concurrency with Algebraic Effects
- Pearls of Algebraic Effects and Handlers
- Retrofitting Effect Handlers onto OCaml
- A concurrent round-robin scheduler
- Mutable state
- ML-style refs
- Transactional state
- Asynchronous IO in direct-style
- Dynamic wind
- Deriving generator from any interator
- Promises
- Monadic reflection
- MVars
- Chameneos-redux
- Message-passing pipeline: Sieve of Eratostheneses
- Deep pipes
- Non termination from effects
- Continuation cloning is tricky
- A solution to the Same Fringe Problem
- Reverse-mode Algorithmic Differentiation
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.
- Delimcc encoding
- Nondeterminism
- Backtracking N-Queens
- Memoization
- A mathematical game: Nim
- Dynamic State
To run the examples with OCaml, be sure to install Opam with these instructions.
# After cloning this repository, create a 5.1 switch
opam update
opam switch create 5.1.1
opam install . --deps-onlyRunning 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
These are other examples that utilise OCaml effect handlers that are not in this repo:
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.