Algebraic Effects: Another mistake carried through to perfection?

11 points by veqq


osa1

I found this incoherent and extremely verbose, and difficult to read. But from a quick look, they are right that checked exceptions and static effects have the same problem, except the problem is exacerbated in static effect systems, because checked exceptions are just one type of effect. In an application there will be many more.

My thoughts on this is that effect systems are basically “functional programming, the good parts”. I have control over which code has what type of side effects, and how those side effects are performed, without any of the inconveniences and performance issues purely functional programming causes.

The issues with checked exceptions carry over to this style really well though. I recently wrote about this in a Koka discussion (a language with effects and handlers) and I want to solve this issue in my language. Haskell programmer have been dealing with these issues for decades with effect libraries/systems like mtl, which now evolved into much more convenient libraries like effectful. The problem of having a dozen or so effects in function type signatures existed with older and simpler libraries like mtl, and they still exist with more recent ones.

The author makes comparison with parameter passing, which I found strange, given that they mention resumable exceptions ealier in the post. In some systems effects can just be implicit parameter passing under the hood, but this is not true in general. For example, OCaml effect handlers can store the continuation of the effect invocation in the heap and call it later, allowing user-level implementations of threads and schedulers like Eio, and testing concurrent programs with model checking. In addition to the same flexibility, Koka allows continuations to be entered multiple times, allowing user-level implementation of fork. You can’t do these by implicitly passing functions and calling them (unless the function you pass invokes an effect, in which case you’re back just hiding effect invocation with a function call).