On Tue, Mar 13, 2012 at 4:57 AM, Simon Marlow <span dir="ltr"><<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>></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 <<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>>> 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'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'm a little bit confused.<br>
<br>
atomicModifyMutVar#<br>
:: MutVar# s a -> (a -> b) -> State# s -> (# 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 "unboxed polymorphic type" you're referring to the "MutVar# s a"? Perhaps the confusion is around the term "unboxed" - we normally say that MutVar# is "unlifted" (no _|_), but it is not "unboxed" because its representation is a pointer to a heap object.</blockquote>
<div> </div><div>I was talking about the (a -> b). I used it because the extraction of 'c' rather than a proper pair was closest to my situation. A less confused example might be newArray# which accepts a polymorphic 'a'.</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't be done reliably. For dataToTag# the compiler automatically inserts the seq just before code generation if it can'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>