Gleam, a statically typed language for the Erlang VM

In typing systems it’s just a way to control the context that is being executed. I even made a play library to emulate it (as much as I could do without performing manual CPS expansion, which is much easier to do when you are making a language from scratch rather than modifying Elixir AST) in Elixir. ^.^

In OCaml there are some good examples of it in a variety of places using it’s forked system:

(the top two links in the readme are great!)

(this is both how to acquire the forked ocaml effects compilers and how to use it, just the docs on how to use it are very useful)

And of course the main discussion on OCaml’s AE system at ocamllabs:
http://ocamllabs.io/doc/effects.html

I can also detail anything from what it is good for (though the above links do very good at that I think) all to how to implement it (on the beam even, the beam doesn’t support proper continuations but with a little bit of CPS transformation in your code generation, which you might be doing already for other purposes, its actually quite efficient at it because of immutability) so feel free to ask anything in detail. :slight_smile:

EDIT: Just to ‘whet your whistle’, some features that Algebraic Effects can add to a fully-typed fully-immutable language like compiling to the BEAM, and all of these can be implemented in usercode itself, not as a language construct:

  • Mutable variable (yes, as a language construct!)
  • Exceptions (ditto!)
  • Concurrency, even Actor-style concurrency (Erlang/Actor style concurrency is one of the examples for concurrent work in ocaml AE examples on occasion)
  • And so so much more, all type safe and functional.

Now ‘proper’ AE of course requires a backend with multi-resumeable continuations, and normally doing those in a non-immutable language is…not cheap, but the BEAM is fully immutable so doing a trivial CPS transformation on all calls (or only on needed calls if your function types can hold that information, which is a very useful optimization) gets you it mostly for free. :slight_smile:

6 Likes