I just read this blog post which argues that monads might be too obscure or difficult to understand as the default "interface to the impure world" in purely functional programming languages; instead, it suggests that the actor model would be more comprehensible when it comes to pedagogy. That may be true -- I do think that actors are easier to understand than monads -- but the post leaves a lot to be desired. In particular, the author offers no examples of what this sort of actor-based purely-functional language would look like, and he doesn't seem to have followed up on the blog post since it was written a few years ago.

So my question is: in what way can actors be leveraged to capture side-effects in a purely functional way? How would source code in that hypothetical language look? What advantages/disadvantages would that approach offer in comparison to monads (outside of the cosmetic differences)?


1 Answer 1


Erlang is an example. I actually don't know Erlang, so I'm going to use some pseudocode:

Suppose you have two threads, Alice and Bob. They talk by calling each other's Send member route, which blocks until the other end replies. Alice can keep some "mutable state" for a single integer as follows:

  function main_loop(state):
     message = Receive()
     if message == "get":

  Alice.Send(100) // Store 100 into the mutable state
  Alice.Send("get") // obtain the 100
  Alice.Send(200) // Store 200
  Alice.Send("get") // get the 200

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.