Generalize util.backtrack over Monad