The reasonable effectiveness of the continuation monad

Just one or two more posts and that will have been a good month for my blog.

@lyxia The trick of running the continuation and messing with the return value in order to get Writer and RState is sweet. It also makes the time travel component of RState/Tardis super easy to reason about

@lyxia Also, until I read this I thought for some reason that Tardis-like functionality was a trick solely enabled by laziness, but actually you can do it with only recursion. The state is just what gets threaded through the arguments, and the reverse state is what's threaded through the return values!

I was inspired to solve the classic trapping rain water problem in C++, using your formulation of Tardis to do it in a single recursive pass.

Sign in to participate in the conversation

Welcome to your niu world ! We are a cute and loving international community O(≧▽≦)O !