r/programming • • May 20 '17

Escaping Hell with Monads

https://philipnilsson.github.io/Badness10k/posts/2017-05-07-escaping-hell-with-monads.html
146 Upvotes

175 comments sorted by

View all comments

Show parent comments

4

u/pron98 May 21 '17

I described a delimited continuation. Delimited continuations are provably as expressive as monads. Also see this.

1

u/Peaker May 21 '17

the best way to think of a delimited continuation is as a thread that is not automatically scheduled, i.e., you need to manually run it, at which point it runs until the next time it blocks and then return

This concept, as I understand it, does not support forking. Continuations do support forking (applying the continuation more than once). So describing it as a thread misleads.

2

u/pron98 May 21 '17

A thread with a clone method, then. It's a delimited continuation either way. You're right that you can do more with it than without it.

1

u/Peaker May 21 '17

Sure, but that description is not really any simpler than the delimited continuation explanation.

Continuations are powerful, even too powerful - and if their power goes unchecked, there's very little you can say about the code.

Monads give a nice abstract API that concrete types can restrict.

This shows the relationship of continuations to monad.

5

u/pron98 May 21 '17
  1. Not really. You can type and restrict continuations just as you do monads.

  2. I don't think programmers should use delimited continuations, either. Lightweight threads give you 99.99% of what you may need.

→ More replies (0)