<br><br><div class="gmail_quote">On Mon, Feb 25, 2013 at 4:11 PM, Simon Peyton-Jones <span dir="ltr">&lt;<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div link="blue" vlink="purple" lang="EN-GB">
<div><div class="im">
<p class="MsoNormal" style="margin-left:36.0pt">I suppose we want an instance<br>
forall k. instance Typeable (k -&gt; *) (Proxy k)<br>
<br>
<span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u><u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">Yes, that looks right.<u></u><u></u></span></p><div class="im">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt">So the universally quantified kind variables of the tycon should end up universally<br>
quantified in the instance as well. How does this translate to the ds_tvs, ds_tys, and<br>
ds_tc_args arguments of a DerivSpec<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#1f497d">My instinct is that the ds_tvs include both type and kind variables, kind variables first.  The kinds of the type variables can mention the kind variables.</span></p>

</div></div></blockquote><div><br>We don&#39;t have any type variables, we want to drop those, as we&#39;ll get those instances<br>via the `(Typeable f, Typeable a) =&gt; Typeable (f a)` instance.<br><br>In my branch, I currently get standalone deriving to give me the following for this<br>

example (tc-trace):<br><br><div style="margin-left:40px">Standalone deriving;<br>  tvs: [k]<br>  theta: []<br>  cls: Typeable<br>  tys: [k -&gt; *, Proxy k]<br>Standalone deriving:<br>  class: Typeable<br>  class types: [k -&gt; *]<br>

  type: Proxy k<br></div><br>This looks good to me. However, the generated instance is not what<br>I think it should be (ddump-types):<br><br><div style="margin-left:40px">instance Typeable (forall (k :: BOX). k -&gt; *) (Proxy k)<br>

</div><br>The forall should be outside, as now the `k` in `Proxy k` is out of scope.<br>I just don&#39;t know how to craft such a DerivSpec... what I have now is:<br><br><div style="margin-left:40px">DS { ds_loc = loc, ds_orig = orig, ds_name = dfun_name, ds_tvs = tvs<br>

    , ds_cls = cls, ds_tys = tyConKind tycon : [mkTyConApp tycon tc_args]<br>    , ds_tc = tycon, ds_tc_args = tc_args<br>    , ds_theta = mtheta `orElse` [], ds_newtype = False })  }<br></div><br>(I filter the type variables from the tc_args before this stage, leaving only kind variables.)<br>

<br><br>Cheers,<br>Pedro<br><br></div></div>