title: Specification of `State#`
body: <p>However, the <a href="http://hackage.haskell.org/package/STMonadTrans-0.4.3/docs/Control-Monad-ST-Trans.html" rel="nofollow noreferrer">documentation for <code>STT</code></a> says:</p>
  
  <blockquote>
    <p>This monad transformer should not be used with monads that can contain multiple answers, like the list monad. The reason is that the state token will be duplicated across the different answers and this causes Bad Things to happen (such as loss of referential transparency). Safe monads include the monads State, Reader, Writer, Maybe and combinations of their corresponding monad transformers.</p>
  </blockquote>
  
  <p>I would like to be able to judge for myself whether a certain use of the <code>STT</code> monad is safe. In particular, I want to understand the interaction with the List monad. I know that <code>STT sloc (ListT (ST sglob)) a</code> is <a href="https://stackoverflow.com/questions/51874362/combine-st-and-list-monads-in-haskell">unsafe</a>, but what about <code>STT sloc []</code>?</p>
  
  <p>I figured out that (at least in GHC), <code>STT</code> is ultimately implemented using magical constructs like <code>MuteVar#</code>, <code>State#</code>, <code>realWorld#</code> etc. Is there any accurate documentation on how these objects behave?</p>
  
  <p>This is closely related to an <a href="https://stackoverflow.com/questions/51874362/combine-st-and-list-monads-in-haskell">earlier question of mine</a>.</p>