I would use the State monad rather than passing the state explicitly. Then the "body of the loop" is of type "m a" rather than "a -> m a", and you can use "sequence . repeat" on it.

-Karl