On Tue, Mar 13, 2012 at 4:57 AM, Simon Marlow <span dir="ltr">&lt;<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 12/03/2012 14:22, Edward Kmett wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Mon, Mar 12, 2012 at 6:45 AM, Simon Marlow &lt;<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a><br></div><div class="im">
&lt;mailto:<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>&gt;&gt; wrote:<br>
        But I can only pass unboxed types to foreign prim.<br>
<br>
        Is this an intrinsic limitation or just an artifact of the use cases<br>
        that have presented themselves to date?<br>

<br>
    It&#39;s an intrinsic limitation - the I# box is handled entirely at the<br>
    Haskell level, primitives only deal with primitive types.<br>

<br>
Ah. I was reasoning by comparison to atomicModifyMutVar#, which deals<br>
with unboxed polymorphic types, and even lies with a too general return<br>
type. Though the result there is returned in an unboxed tuple, the<br>
argument is passed unboxed.<br>
<br>
Is that implemented specially?<br>
</div></blockquote>
<br>
I&#39;m a little bit confused.<br>
<br>
atomicModifyMutVar#<br>
   :: MutVar# s a -&gt; (a -&gt; b) -&gt; State# s -&gt; (# State# s, c #)</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is the &quot;unboxed polymorphic type&quot; you&#39;re referring to the &quot;MutVar# s a&quot;?  Perhaps the confusion is around the term &quot;unboxed&quot; - we normally say that MutVar# is &quot;unlifted&quot; (no _|_), but it is not &quot;unboxed&quot; because its representation is a pointer to a heap object.</blockquote>
<div> </div><div>I was talking about the (a -&gt; b). I used it because the extraction of &#39;c&#39; rather than a proper pair was closest to my situation. A less confused example might be newArray# which accepts a polymorphic &#39;a&#39;.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"></div>
The problem is, that can&#39;t be done reliably.  For dataToTag# the compiler automatically inserts the seq just before code generation if it can&#39;t prove that the argument is already evaluated, I think we would want to do the same thing for unsafeField#.<br>
</blockquote><div><br></div><div>Fair enough. </div><div><br></div><div>Thanks again.</div><div><br></div><div>-Edward</div></div>