State monad <-> fold