<div dir="ltr">See <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.114.6907&rep=rep1&type=pdf">Scrap more boilerplate: reflection, zips, and generalised casts by Ralf Lämmel and Simon Peyton Jones</a> for why gcast1 and dataCast1 exist as they do.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 17, 2015 at 8:58 PM, Ryan Scott <span dir="ltr"><<a href="mailto:ryan.gl.scott@gmail.com" target="_blank">ryan.gl.scott@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It does seem unnecessary. The Data instance for Proxy is manually written in Data.Data:<br><br><pre><span>proxyConstr</span> <span>::</span> <span>Constr</span>
<a name="14e9eabb731ae300_line-1335"></a><span>proxyConstr</span> <span>=</span> <span>mkConstr</span> <span>proxyDataType</span> <span>"Proxy"</span> <span>[]</span> <span>Prefix</span>
<a name="14e9eabb731ae300_line-1336"></a>
<a name="14e9eabb731ae300_line-1337"></a><a name="14e9eabb731ae300_proxyDataType"></a><span>proxyDataType</span> <span>::</span> <span>DataType</span>
<a name="14e9eabb731ae300_line-1338"></a><span>proxyDataType</span> <span>=</span> <span>mkDataType</span> <span>"Data.Proxy.Proxy"</span> <span>[</span><span>proxyConstr</span><span>]</span><a name="14e9eabb731ae300_line-1339"></a></pre><br><pre><a name="14e9eabb731ae300_line-1340"></a><a name="14e9eabb731ae300_instance Data (Proxy t)"></a><span>instance</span> <span>(</span><span>Data</span> <span>t</span><span>)</span> <span>=></span> <span>Data</span> <span>(</span><span>Proxy</span> <span>t</span><span>)</span> <span>where</span>
<a name="14e9eabb731ae300_line-1341"></a> <span>gfoldl</span> <span>_</span> <span>z</span> <span>Proxy</span> <span>=</span> <span>z</span> <span>Proxy</span>
<a name="14e9eabb731ae300_line-1342"></a> <span>toConstr</span> <span>Proxy</span> <span>=</span> <span>proxyConstr</span>
<a name="14e9eabb731ae300_line-1343"></a> <span>gunfold</span> <span>_</span> <span>z</span> <span>c</span> <span>=</span> <span>case</span> <span>constrIndex</span> <span>c</span> <span>of</span>
<a name="14e9eabb731ae300_line-1344"></a> <span>1</span> <span>-></span> <span>z</span> <span>Proxy</span>
<a name="14e9eabb731ae300_line-1345"></a> <span>_</span> <span>-></span> <span>error</span> <span>"Data.Data.gunfold(Proxy)"</span>
<a name="14e9eabb731ae300_line-1346"></a> <span>dataTypeOf</span> <span>_</span> <span>=</span> <span>proxyDataType</span>
<a name="14e9eabb731ae300_line-1347"></a> <span>dataCast1</span> <span>f</span> <span>=</span> <span>gcast1</span> <span>f</span>
<span style="font-family:arial,helvetica,sans-serif"><a name="14e9eabb731ae300_line-1348"><br></a></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">If dataCast1 weren't defined to be gcast1, then that instance would only require a Typeable t constraint, which would make it polykinded. To be honest, I'm not sure why gcast1 requires a Data t constraint (I don't use Data that often, so hopefully someone more knowledgeable than me can answer this).<br></span></pre></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>