Hacker News new | past | comments | ask | show | jobs | submit login

The trouble with this style is that your sublanguage program is no longer a value, so you can't reason about it or treat it as one. Instead you've created, effectively, an imperative method that accepts a bunch of callbacks that implements effects and runs those.

I mean, the imperative programmers already knew they could write programs full of effects without monads. But there's a reason we regard that as bad style. As far as I can tell this piece is just a longwinded reinvention of imperative programming?

Yes, the program is written in terms of callbacks, just like monadic programs are written in terms of "return" and "bind" callbacks. This style isn't any more imperative than monadic programming. You could port this code to Haskell (using typeclasses instead of modules) and it'd work just as well.

Tagless final style programs are indeed written in terms of "return" and "bind" callbacks, but programs written with "vernacular monads" or free coproduct style aren't - they're plain old values and can be inspected as such. That's the style I prefer.

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