state monad encoded as continuation