I think continuations (a.k.a. callbacks) are much easier to explain than the current
State# RealWorld
business.
-
Understanding Callbacks and Callback Hell in JavaScript - GeeksforGeeks
(
…with JS doing for continuations what Haskell is doing for the monadic interface;-)
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