<br><br><div class="gmail_quote">2011/11/4 Bas van Dijk <span dir="ltr">&lt;<a href="mailto:v.dijk.bas@gmail.com">v.dijk.bas@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Thanks José!<br>
<br>
Will this make it into ghc-7.4?<br></blockquote><div><br></div><div>Yes, I think so.</div><div><br></div><div><br></div><div>Cheers,</div><div>Pedro</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


<span class="HOEnZb"><font color="#888888"><br>
Bas<br>
</font></span><div class="im HOEnZb"><br>
2011/11/4 José Pedro Magalhães &lt;<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>&gt;:<br>
</div><div class="HOEnZb"><div class="h5">&gt; Hi,<br>
&gt; Now, for the following datatype:<br>
&gt; data X a = X { myX :: a } deriving Generic<br>
&gt; You get the following -ddump-deriv output:<br>
&gt; ==================== Derived instances ====================<br>
&gt; Derived instances:<br>
&gt;   instance GHC.Generics.Generic (Temp.X a_adY) where<br>
&gt;     GHC.Generics.from (Temp.X g1_aeG)<br>
&gt;       = GHC.Generics.M1<br>
&gt;           (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.K1 g1_aeG)))<br>
&gt;     <a href="http://GHC.Generics.to" target="_blank">GHC.Generics.to</a><br>
&gt;       (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.K1<br>
&gt; g1_aeH))))<br>
&gt;       = Temp.X g1_aeH<br>
&gt;<br>
&gt;   instance GHC.Generics.Datatype Temp.D1X where<br>
&gt;     GHC.Generics.datatypeName _ = &quot;X&quot;<br>
&gt;     GHC.Generics.moduleName _ = &quot;Temp&quot;<br>
&gt;<br>
&gt;   instance GHC.Generics.Constructor Temp.C1_0X where<br>
&gt;     GHC.Generics.conName _ = &quot;X&quot;<br>
&gt;     GHC.Generics.conIsRecord _ = GHC.Types.True<br>
&gt;<br>
&gt;   instance GHC.Generics.Selector Temp.S1_0_0X where<br>
&gt;     GHC.Generics.selName _ = &quot;myX&quot;<br>
&gt;<br>
&gt; Generic representation:<br>
&gt;<br>
&gt;   Generated datatypes for meta-information:<br>
&gt;     Temp.D1X<br>
&gt;     Temp.C1_0X<br>
&gt;     Temp.S1_0_0X<br>
&gt;<br>
&gt;   Representation types:<br>
&gt;     Temp.Rep_X = GHC.Generics.D1<br>
&gt;                    Temp.D1X<br>
&gt;                    (GHC.Generics.C1<br>
&gt;                       Temp.C1_0X<br>
&gt;                       (GHC.Generics.S1 Temp.S1_0_0X (GHC.Generics.Par0<br>
&gt; a_adY)))<br>
&gt; Still not perfect, in that the representation type should really appear as a<br>
&gt; type instance inside the Generic instance, but at least all the important<br>
&gt; information is printed.<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Pedro<br>
&gt;<br>
&gt; 2011/11/3 Bas van Dijk &lt;<a href="mailto:v.dijk.bas@gmail.com">v.dijk.bas@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; 2011/11/3 José Pedro Magalhães &lt;<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>&gt;:<br>
&gt;&gt; &gt; &quot;-ddump-deriv&quot; will print (most of) it.<br>
&gt;&gt;<br>
&gt;&gt; But it doesn&#39;t print the most useful piece of information: the<br>
&gt;&gt; definition of Rep.<br>
&gt;&gt;<br>
&gt;&gt; It would be great if this could be added.<br>
&gt;&gt;<br>
&gt;&gt; Currently when I have a type that I want to know the Rep of, say:<br>
&gt;&gt;<br>
&gt;&gt; data Foo = Bar Int<br>
&gt;&gt;         | Boo {hello :: String}<br>
&gt;&gt;           deriving Generic<br>
&gt;&gt;<br>
&gt;&gt; I just convert it to a Rep and show it:<br>
&gt;&gt;<br>
&gt;&gt; err = show $ from $ Boo &quot;World&quot;<br>
&gt;&gt;<br>
&gt;&gt; However Reps don&#39;t have Show instances so GHC complains:<br>
&gt;&gt;<br>
&gt;&gt; No instance for<br>
&gt;&gt;  (Show (D1 D1Foo (   C1 C1_0Foo (S1 NoSelector (Rec0 Int))<br>
&gt;&gt;                  :+: C1 C1_1Foo (S1 S1_1_0Foo (Rec0 String))<br>
&gt;&gt;                  )<br>
&gt;&gt;         x0<br>
&gt;&gt;        )<br>
&gt;&gt;  )<br>
&gt;&gt;  arising from a use of `show&#39;<br>
&gt;&gt;<br>
&gt;&gt; And there you go. This is the only time when I&#39;m happy to see an error<br>
&gt;&gt; message :-)<br>
&gt;&gt;<br>
&gt;&gt; Bas<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>