Monads are inferior to function arguments for effect control

Epistemic status: Extremely hot take, did not even consult the notes I wrote on this months ago. Have not convinced myself that this is wrong though, it's pretty intuitive to me.

Traditional monads are obviously inferior to a good effect system, so I'll leave that step of the argument as an exercise for the reader. :)

But an effect system is essentially just one-shot delimited continuations in a typed language.

And one-shot delimited continuations are basically just linearly-typed CSP channels, or Smalltalk objects, or whatever, passed through dynamically scoped variables. You can reproduce one-shot continuations by just sending messages around and blocking for a response. You could do it with normal old message-passing objects, as long as your objects can arbitrarily decide which order in which to respond to messages, up to and including never responding to some messages. The delimited part can be achieved with some mumble dynamic scoping mumble ban closures mumble.

And really, what we're essentially doing with an effect system is implicitly passing down the capability to perform an effect. Such a representation is equally expressive as a normal effect system! (As long as you have a powerful enough representation of a "capability")

And doing things implicitly is, of course, bad. Even though dynamic scope/implicit parameters provides a lot of nifty features, it's probably ultimately bad for us. (This means you, typeclasses!)

So why don't we just explicitly pass effect-capabilities down? Yes, yes, it's going to be very boilerplatey, but who cares!

Capabilities are an extremely intuitive model for handling IO, at least for traditional imperative programmers, so I bet we'd see more uptake from the world at large, if we just represented IO the dumb and boilerplatey way. Monads and effect systems are already boilerplatey anyway.

We would have to ban closures, maybe, but oh well, you have to make some sacrifices for progress.

Though, I think you might need some substructural types to get this really working? Dunno, have to consult my notes…

Created: 2018-09-23 Sun 03:55

Validate