# Is anyone using the effect system for ALL side-effects?

**URL:** <https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998>\
**Category:** Community\
**Tags:** effects, algebraic-effects\
**Created:** [July 21, 2025, 8:50am UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998 "2025-07-21T08:50:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![olleharstedt](https://avatars.discourse-cdn.com/v4/letter/o/f1d935/32.png) [@olleharstedt](https://discuss.ocaml.org/u/olleharstedt)\
**Post date:** [July 21, 2025, 8:50am UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/1 "2025-07-21T08:50:26Z")

</div>

Just curious if this started to become idiomatic in the OCaml ecosystem, to use effects not only for parallelism and concurrency, but for all side-effects, like writing to std/out, database and file access, etc?

---

<div class="post-metadata">

**Author:** ![xvw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvw/32/2041_2.png) [@xvw](https://discuss.ocaml.org/u/xvw)\
**Post date:** [July 21, 2025, 12:03pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/2 "2025-07-21T12:03:11Z")

</div>

We use it on YOCaml: [GitHub - xhtmlboi/yocaml: YOCaml is a static site generator, mostly written in OCaml](https://github.com/xhtmlboi/yocaml)

You can watch the Eff module here: [yocaml/lib/core/eff.ml at main · xhtmlboi/yocaml · GitHub](https://github.com/xhtmlboi/yocaml/blob/main/lib%2Fcore%2Feff.ml)

But from my point of view, when I don’t care about continuation (or exception are sufficient to discard the execution) I relay on modules like here: [GitHub - xvw/kohai: Kohai is a very simple (but opinionated) timetracker for my personal usage](https://github.com/xvw/kohai) or objects (yeah, I love using OCaml OOP features for dependency injection)

---

<div class="post-metadata">

**Author:** ![olleharstedt](https://avatars.discourse-cdn.com/v4/letter/o/f1d935/32.png) [@olleharstedt](https://discuss.ocaml.org/u/olleharstedt)\
**Post date:** [July 21, 2025, 1:06pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/3 "2025-07-21T13:06:54Z")

</div>

> [@xvw](#):
>
> You can watch the Eff module here: [yocaml/lib/core/eff.ml at main · xhtmlboi/yocaml · GitHub](https://github.com/xhtmlboi/yocaml/blob/main/lib%2Fcore%2Feff.ml)

This is so above my head, sorry. 😰

---

<div class="post-metadata">

**Author:** ![JohnJ](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/johnj/32/6020_2.png) [@JohnJ](https://discuss.ocaml.org/u/JohnJ)\
**Post date:** [July 21, 2025, 1:24pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/4 "2025-07-21T13:24:51Z")

</div>

See also this previous discussion: [Curious about real-world uses of the effect system (other than threading)](https://discuss.ocaml.org/t/curious-about-real-world-uses-of-the-effect-system-other-than-threading/16581) To summarize my response there, I find it useful for managing global mutable state in a functional style. I can’t imagine myself using it for _all_ effectful code, though, at least not for the foreseeable future.

---

<div class="post-metadata">

**Author:** ![olleharstedt](https://avatars.discourse-cdn.com/v4/letter/o/f1d935/32.png) [@olleharstedt](https://discuss.ocaml.org/u/olleharstedt)\
**Post date:** [July 28, 2025, 11:36am UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/5 "2025-07-28T11:36:10Z")

</div>

Just a NB, the programming language [Elm](https://guide.elm-lang.org/) is kinda working like this, but they call it messages, not effects.

Might be interesting to test a similar paradigm with `js_of_ocaml`. 🙂

---

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [July 28, 2025, 3:05pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/6 "2025-07-28T15:05:58Z")

</div>

Could you point to some documentation or discussion on that? I am interested, but see nothing obviously relevant on the linked page.

---

<div class="post-metadata">

**Author:** ![dangdennis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dangdennis/32/2594_2.png) [@dangdennis](https://discuss.ocaml.org/u/dangdennis)\
**Post date:** [July 28, 2025, 3:31pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/7 "2025-07-28T15:31:36Z")

</div>

[Commands and Subscriptions · An Introduction to Elm](https://guide.elm-lang.org/effects/) is the more specific page.

To model side effects, Elm requires you to send messages as Commands, `Cmd MyType`. So if you want to make an HTTP request within the browser, your Elm code would typically send a `Cmd Msg` via the http lib. A command is like an IO type in haskell. Represents possible side effects.

---

<div class="post-metadata">

**Author:** ![xvw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvw/32/2041_2.png) [@xvw](https://discuss.ocaml.org/u/xvw)\
**Post date:** [July 28, 2025, 4:02pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/8 "2025-07-28T16:02:49Z")

</div>

There is a lot of project that encode Moore Machine and Mealy Machine at the browser level, based on js\_of\_ocaml. We can notably mention:

- [GitHub - LexiFi/ocaml-vdom: Elm architecture and (V)DOM for OCaml](https://github.com/lexifi/ocaml-vdom)
- [GitHub - janestreet/bonsai: A library for building dynamic webapps, using Js\_of\_ocaml](https://github.com/janestreet/bonsai)
- [GitHub - hbr/fmlib: Functional Monadic Library for Ocaml](https://github.com/hbr/fmlib)

And they use (at different levels of convergence) this notion of pairs between declarative UI rendering, model recalculation by messages, and the use of commands as an alternative channel.

---

<div class="post-metadata">

**Author:** ![mattiadg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mattiadg/32/6134_2.png) [@mattiadg](https://discuss.ocaml.org/u/mattiadg)\
**Post date:** [August 25, 2025, 10:56pm UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/9 "2025-08-25T22:56:48Z")

</div>

I’m new to Ocaml, so sorry if the question may sound stupid. But why did you need to write all your monadic operators, including return and bind? Is there no out-of-the-box support at the language level, or libraries to do that?

I don’t really have an experience with it, but when reading about functional programming languages I found that Scala has big libraries for effect systems, which are kind of the selling points of the language. Is there nothing comparable to it in Ocaml?

---

<div class="post-metadata">

**Author:** ![xvw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/xvw/32/2041_2.png) [@xvw](https://discuss.ocaml.org/u/xvw)\
**Post date:** [August 26, 2025, 9:20am UTC](https://discuss.ocaml.org/t/is-anyone-using-the-effect-system-for-all-side-effects/16998/10 "2025-08-26T09:20:57Z")

</div>

I am aware about [GitHub - BinaryAnalysisPlatform/bap: Binary Analysis Platform](https://github.com/BinaryAnalysisPlatform/bap) and [GitHub - xvw/preface: Preface is an opinionated library designed to facilitate the handling of recurring functional programming idioms in OCaml.](https://github.com/xvw/preface) (obviously aware) but our goal was to reduce must as possible dependencies.

For _kind of effect abstraction_ I will mention [gr-im.github.io - Basic dependency injection with objects](https://gr-im.github.io/a/dependency-injection.html) which illustrate what I mean by “_yeah, I love using OCaml OOP features for dependency injection_”.
