<![endif] Menu Skip to content Search for: #site-navigation #navbar #masthead August 10, 2008 Uncategorized code , haskell Luke .entry-meta .entry-header Someone in the #haskell IRC channel mentioned the “reverse state monad” explaining that it used the state from the next computation and passed it to the previous one. Well, I just had to try this! First, a demonstration: we will compute the fibonacci numbers by starting with them and mapping them back to the empty list. -- cumulativeSums [1,2,3,4,5] = [0,1,3,6,10,15] cumulativeSums = scanl (+) 0 computeFibs = evalRState [] $ do -- here the state is what we want: the fibonacci numbers fibs <- get modify cumulativeSums -- now the state is the difference sequence of -- fibs, [1,0,1,1,2,3,5,8,13,...], because the -- cumulativeSums of that sequence is fibs. Notice -- that this ...