top | item 4349221

(no title)

joshzayin | 13 years ago

The readme does in fact make that claim: "The Reverse State monad allows you to do the reverse: send information backwards to the past, or receive information from the future."

I'm curious as to what exactly that means, but without further explanation I'm going to assume that the thing running in the "past" just waits for information from the "future". It's possible they mean something else, of course, but that's my first guess.

discuss

order

EvilTerran|13 years ago

Well, the past doesn't necessarily have to wait for the value from the future to arrive, thanks to lazy evaluation. But yes, you've got the basic gist of it.

State and Reverse State are both about having a single conceptually-mutable "cell" (although that can, of course, be a complex value like a mapping or whatever), written with "put" and read with "get" -- take a minimal example:

  do put "Past"
     x <- get
     put "Future"
     return x
In State, that would result in "Past"; in Reverse State, it would result in "Future".

The blog posts linked at the bottom of the readme may help make things clearer.