# Fun with Algebraic Effects - from Toy Examples to Hardcaml Simulations

DevFeed: [Fun with Algebraic Effects - from Toy Examples to Hardcaml Simulations](<https://devfeed.tech/articles/fun-with-algebraic-effects-from-toy-examples-to-hardcaml-simulations-20168.md>)

Original publisher: [Read original article](<https://blog.janestreet.com/fun-with-algebraic-effects-hardcaml/>)

Author: Fu Yong Quah

Published: 2026-01-06T00:00:00Z

Content type: article

Language: en

Sources: [Jane Street](<https://devfeed.tech/sources/jane-street.md>)

Topics: [OCaml](<https://devfeed.tech/topics/ocaml.md>), [Library](<https://devfeed.tech/topics/library.md>), [Simulation](<https://devfeed.tech/topics/simulation.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [code](<https://devfeed.tech/tags/code.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [library](<https://devfeed.tech/tags/library.md>), [ocaml](<https://devfeed.tech/tags/ocaml.md>)

## AI overview

The article describes porting Jane Street's Hardcaml_step_testbench library from monads to algebraic effects in OCaml 5. It explains algebraic effects, compares them with monads, and demonstrates how to use them with the Handled_effect library for Hardcaml simulations.

## Source excerpt

I recently ported the Hardcaml_step_testbench library, one of the libraries that we use at Jane Street for Hardcaml simulations, from using monads to using algebraic effects, a new OCaml 5 feature. This blog post walks through what algebraic effects are, why you should consider using them in lieu of monads, and how to actually work with them using the Handled_effect library. One thing I've come to believe is that most of what can be done with monads can be done with algebraic effects in a much more elegant way.