ocaml-multicore / effects-examples

Examples to illustrate the use of algebraic effects in Multicore OCaml
ISC License
417 stars 35 forks source link

Fix dynamic_state to use new Effect syntax #40

Closed tmcgilchrist closed 7 months ago

tmcgilchrist commented 7 months ago

Fix dynamic_state to use new Effect syntax, could possibly be simplified further. The type checking inside the effect handlers is a bit fragile, if you reorder the matches in run or run2 they no longer type check.

version 1 fails with Exception: Stdlib.Effect.Unhandled(LocalState(R).New(1)) version 2 passed with int = 5 version 3 I couldn't work out how to run it properly. version 4 passed producing 3 3