Redundant `let`s in list monadic code There is a function with bunch of a redundant lets and ←s inside a list monad. 

example ∷ (Int, Int, Int, Int, Int)
example = head $ do
  let list1 = [0,1]
  e1 ← list1
  let list2 = φ list1 e1
  e2 ← list2
  let list3 = φ list2 e2
  e3 ← list3
  let list4 = φ list3 e3
  e4 ← list4
  let list5 = φ list4 e4
  e5 ← list5
  return (e1,e2,e3,e4,e5)
    where φ ∷ [Int] → Int → [Int]


So, all list# values are unusable. How can example could be rewritten with &gt;&gt;= or maybe with something else to get (e1,e2,e3,e4,e5) without any lets?
Hm, this could probably be done using foldM or similar, but that would require you to convert to and from lists. My first impulse would be to try to write the top-level of example using Applicative style:

import Control.Applicative

example = head $ (,,,,) &lt;$&gt; m &lt;*&gt; m &lt;*&gt; m &lt;*&gt; m &lt;*&gt; m


But that doesn't work directly here, as you want each m to know the list# of the last action.

One way to realize this without breaking up the above structure would be to have a StateT monad transformer take care of passing around the current list#:

import Control.Monad.State

example = head $ flip evalStateT [0,1] $
          (,,,,) &lt;$&gt; m &lt;*&gt; m &lt;*&gt; m &lt;*&gt; m &lt;*&gt; m


This allows us to write m as a list monad with state:

  where m :: StateT [Int] [] Int
        m = do list &lt;- get
               e &lt;- lift list
               put (phi list e)
               return e


Now admittedly, this is a bit advanced. It might be easier to try to restructure phi or use a foldM type solution.