Dialogues vs continuations (and algebraic effects) to implement I/O

I think continuations (a.k.a. callbacks) are much easier to explain than the current State# RealWorld business.


I imagine performance was the biggest consideration; using a lambda for every continuation is not free.

There’s another problem - reuse of exposed continuations:

(\ k -> k 1 + k 2)

…much like reuse of exposed State# RealWorld values, both of which are solved by using an abstract data type…which then leaves the choice of interface that abstract type should use:


[…] you have laws which tell you how those I/O operations behave […]

So would this entail:

  • adding new laws for each FFI I/O call?
  • then checking what other I/O laws are affected?

That looks rather like O(n 2) complexity to me - alright for a few primitive or FFI I/O operations; not so wonderful if you’re using a lot of them. And remember - side effects are arbitrary, so there can be an arbitrary number of them…


Plotkin and Power, 2003