Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, continuations can be controlled similarly through effect polymorphism, which is what I was trying to describe.

The difference is not that continuations allow anything at all, but that your effects are commutative rather than layered like a monad transformer stack.



> continuations can be controlled similarly through effect polymorphism, which is what I was trying to describe.

Fair enough, but you're effectively talking about a secondary, novel type system, right? One of the things I like about monads is that they can be just plain old values of plain old datatypes.

> The difference is not that continuations allow anything at all, but that your effects are commutative rather than layered like a monad transformer stack.

Yeah, monad transformers do feel overly cumbersome for the cases where effects do commute. The trouble is that some effects don't commute, and I've yet to see a formalism that had a good solution to distinguishing effects that commute from those that don't. (I read a paper about a tensor product construct once, but couldn't really follow how it was supposed to work in practice)


> you're effectively talking about a secondary, novel type system, right?

Yes, exactly.

The main reason I prefer language-level effects rather than monads is for composability with normal imperative control flow. Monads are written in terms of higher order functions passing closures around, and that gets really messy in a language where you not only have early return and loops with break and continue, but you also have destructors that need to run as you enter and leave scopes.

You can add that kind of stuff as monads but it gets really messy, and is basically completely untenable in a language like Rust that also cares about memory management. Even if Rust did have HKT, it would still be impossible to write a Monad trait that supports them all, for example.

This article makes some great points on the subject: http://blog.paralleluniverse.co/2015/08/07/scoped-continuati...




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: