r/purescript • • Oct 22 '19

How does the continuation monad work?

https://maxhallinan.com/posts/2019/10/22/how-does-the-continuation-monad-work/
13 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/qqwy Oct 23 '19

One place where they are super useful, is when implementing interpreters or runtime systems for languages that require one or multiple of the following features that might not be baked into the outer language:

  • recursion. (Running CPS on a trampoline is straightforward)
  • coroutines
  • short-circuiting or nonlocal returns.

Check for instance the ElixirConf 2019 US keynote on how Lumen, an Erlang VM for WebAssembly was built. (there are also many other goodies in that talk, unrelated to CPS :-) ).