It seems like the most elegant long-term solution here is to make GeneralizedNewtypeDeriving more cunning. Is there some fundamental reason it can&#39;t work with the type families involved?<div><br></div><div>But in the short term, I agree and TH is probably best.<br>
<br>-Dan<br><br><div class="gmail_quote">On Wed, May 30, 2012 at 3:41 PM, Roman Leshchinskiy <span dir="ltr">&lt;<a href="mailto:rl@cse.unsw.edu.au" target="_blank">rl@cse.unsw.edu.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 30/05/2012, at 05:27, Ben Gamari wrote:<br>
<br>
&gt; Sadly, these two features don&#39;t interact particularly well. While the<br>
&gt; Data.Vector.Unbox documentation claims that &quot;Implementing unboxed<br>
&gt; vectors for new data types can be very easy&quot;, it then goes on to list an<br>
&gt; abridged version of the Complex instance---dozens of lines of<br>
&gt; code. While this code certainly isn&#39;t difficult to write, it is time<br>
&gt; consuming, error-prone, and, above else, utterly mind deadeningly dull<br>
&gt; (making it quite uncharacteristic for Haskell). So dull that I generally<br>
&gt; avoid newtypes at all cost in code that might need to use unboxed<br>
&gt; vectors. This boilerplate is largely due to Vector&#39;s use of type<br>
&gt; families as this precludes the use of (the otherwise quite cunning)<br>
&gt; GeneralizedNewtypeDeriving to automatically derive the necessary<br>
&gt; instances.<br>
<br>
<br>
</div>I completely agree that the current situation is less than ideal but don&#39;t really have a good solution. Frankly, the easiest way of defining Unbox instances for newtypes is probably a preprocessor macro. I use a lot of those in vector to reduce boilerplate and they work well. I&#39;ll provide one for newtypes in the next release.<br>

<br>
As you say, TH is another possibility but one I&#39;m rather wary of.<br>
<span class="HOEnZb"><font color="#888888"><br>
Roman<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>