title: Working on permuted monad transformer stack
body: <p>One of the problems with monad transformers I find is the need to <code>lift</code> the operations into the right monad. A single <code>lift</code> here and there isn't bad, but sometimes there are functions that looks like this:</p>
  
  <pre><code>fun = do
    lift a
    lift b
    c
    lift d
    lift e
    f
  </code></pre>
  
  <p>I would like to be able to write this function thus:</p>
  
  <pre><code>fun = monadInvert $ do
    a
    b
    lift c
    d
    e
    lift f
  </code></pre>
  
  <p>This halves the number of <code>lift</code>s and makes the code cleaner.</p>
  
  <p>The question is: for what monads is <code>monadInvert</code> possible? How should one create this function?</p>
  
  <p>Bonus points: define it for <code>monad m</code> which is an instance of <code>MonadIO</code>.</p>
  
  <p>The title of this question speaks of permutations: indeed, how can we deal with arbitrary permutations of a monad tranformer stack?</p>