> update' s 0 = do
> (a:as) <- get
> let (r, a') = runState s a
> put (a':as)
> return r
> update' s i = do
> (a:as) <- get
> put as
> r <- update' s (i-1)
> as' <- get
> put (a:as')
> return r
Now, this just looks awful. The first half, the base condition, is actually "running" a State calculation. And the second half sets the state within the monad twice!
I like the idea of using State because it simplifies the type. When I see (a -> (b,a)) I say "Wait a second, that's a State calculation, isn't it?" and then, hopefully, generalize. But I can't write that calculation nearly as concisely. How do I do this properly?