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