<br><br><div class="gmail_quote">2011/11/4 Bas van Dijk <span dir="ltr"><<a href="mailto:v.dijk.bas@gmail.com">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;">
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 <<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>>:<br>
</div><div class="HOEnZb"><div class="h5">> Hi,<br>
> Now, for the following datatype:<br>
> data X a = X { myX :: a } deriving Generic<br>
> You get the following -ddump-deriv output:<br>
> ==================== Derived instances ====================<br>
> Derived instances:<br>
> instance GHC.Generics.Generic (Temp.X a_adY) where<br>
> GHC.Generics.from (Temp.X g1_aeG)<br>
> = GHC.Generics.M1<br>
> (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.K1 g1_aeG)))<br>
> <a href="http://GHC.Generics.to" target="_blank">GHC.Generics.to</a><br>
> (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.K1<br>
> g1_aeH))))<br>
> = Temp.X g1_aeH<br>
><br>
> instance GHC.Generics.Datatype Temp.D1X where<br>
> GHC.Generics.datatypeName _ = "X"<br>
> GHC.Generics.moduleName _ = "Temp"<br>
><br>
> instance GHC.Generics.Constructor Temp.C1_0X where<br>
> GHC.Generics.conName _ = "X"<br>
> GHC.Generics.conIsRecord _ = GHC.Types.True<br>
><br>
> instance GHC.Generics.Selector Temp.S1_0_0X where<br>
> GHC.Generics.selName _ = "myX"<br>
><br>
> Generic representation:<br>
><br>
> Generated datatypes for meta-information:<br>
> Temp.D1X<br>
> Temp.C1_0X<br>
> Temp.S1_0_0X<br>
><br>
> Representation types:<br>
> Temp.Rep_X = GHC.Generics.D1<br>
> Temp.D1X<br>
> (GHC.Generics.C1<br>
> Temp.C1_0X<br>
> (GHC.Generics.S1 Temp.S1_0_0X (GHC.Generics.Par0<br>
> a_adY)))<br>
> Still not perfect, in that the representation type should really appear as a<br>
> type instance inside the Generic instance, but at least all the important<br>
> information is printed.<br>
><br>
> Cheers,<br>
> Pedro<br>
><br>
> 2011/11/3 Bas van Dijk <<a href="mailto:v.dijk.bas@gmail.com">v.dijk.bas@gmail.com</a>><br>
>><br>
>> 2011/11/3 José Pedro Magalhães <<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>>:<br>
>> > "-ddump-deriv" will print (most of) it.<br>
>><br>
>> 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>
>><br>
>> Bas<br>
><br>
><br>
</div></div></blockquote></div><br>