Okay, I tested it out and the arrow transformer has the same problem.&nbsp; I realized this after I sent the last message -- the point is that at any particular point, intuitively there should be exactly one copy of a State# s for each state thread, and it should never get duplicated; allowing other monads or arrows to hold a State# s in any form allows them to hold more than one, violating that goal.<br>
<br>I&#39;m not entirely convinced yet that there <i>isn&#39;t</i> some really gorgeous type system magic to fix this issue, like the type-system magic that motivates the type of runST in the first place, but that&#39;s not an argument that such magic exists...it&#39;s certainly an interesting topic to mull.<br>
<br clear="all">Louis Wasserman<br><a href="mailto:wasserman.louis@gmail.com">wasserman.louis@gmail.com</a><br>
<br><br><div class="gmail_quote">On Sun, Feb 15, 2009 at 9:20 PM, Dan Doel <span dir="ltr">&lt;<a href="mailto:dan.doel@gmail.com">dan.doel@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Sunday 15 February 2009 9:44:42 pm Louis Wasserman wrote:<br>
&gt; Hello all,<br>
&gt;<br>
&gt; I just uploaded stateful-mtl and pqueue-mtl 1.0.1. &nbsp;The ST monad<br>
&gt; transformer and array transformer have been removed -- I&#39;ve convinced<br>
&gt; myself that a heap transformer backed by an ST array cannot be<br>
&gt; referentially transparent -- and the heap monad is now available only as a<br>
&gt; basic monad and not a transformer, though it still provides priority queue<br>
&gt; functionality to any of the mtl wrappers around it. &nbsp;stateful-mtl retains a<br>
&gt; MonadST typeclass which is implemented by ST and monad transformers around<br>
&gt; it, allowing computations in the the ST-bound heap monad to perform ST<br>
&gt; operations in its thread.<br>
&gt;<br>
&gt; Since this discussion had largely led to the conclusion that ST can only be<br>
&gt; used as a bottom-level monad, it would be pretty uncool if ST computations<br>
&gt; couldn&#39;t be performed in a monad using ST internally because the ST thread<br>
&gt; was hidden and there was no way to place ST computations &#39;under&#39; the outer<br>
&gt; monad. &nbsp;Anyway, it&#39;s essentially just like the MonadIO typeclass, except<br>
&gt; with a functional dependency on the state type.<br>
&gt;<br>
&gt; There was a question I asked that never got answered, and I&#39;m still<br>
&gt; curious: would an ST *arrow* transformer be valid? &nbsp;Arrows impose<br>
&gt; sequencing on their operations that monads don&#39;t... &nbsp;I&#39;m going to test out<br>
&gt; some ideas, I think.<br>
<br>
</div>Your proposed type:<br>
<br>
 &nbsp;State (Kleisli []) x y = (s, x) -&gt; [(s, y)]<br>
<br>
is (roughly) isomorphic to:<br>
<br>
 &nbsp;x -&gt; StateT s [] y = x -&gt; s -&gt; [(s, y)]<br>
<br>
The problem with an ST transformer is that the state parameter needs to be<br>
used linearly, because that&#39;s the only condition under which the optimization<br>
of mutable update is safe. ST ensures this by construction, as opposed to<br>
other languages (Clean) that have type systems that can express this kind of<br>
constraint directly. However, with STT, whether the state parameter is used<br>
linearly is a function of the wrapped monad. You&#39;d have to give a more fleshed<br>
out version of your proposed state arrow transformer, but off the top of my<br>
head, I&#39;m not sure it&#39;d be any better.<br>
<font color="#888888"><br>
-- Dan<br>
</font></blockquote></div><br>