It could, yes. Actually, using DefaultSignatures you can probably use SYB for defining classes with generic default methods, by adding Data and Typeable constraints instead of Generic.<br><br><br>Cheers,<br>Pedro<br><br><div class="gmail_quote">

2012/3/12 Yves Parès <span dir="ltr">&lt;<a href="mailto:yves.pares@gmail.com">yves.pares@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 for the clarification.<br>
But could not class Data have been used for generic Deriving of classes? I imagine it would have been harder, but I fail to see if would have been possible...<br><br><div class="gmail_quote">

Le 12 mars 2012 16:58, José Pedro Magalhães <span dir="ltr">&lt;<a href="mailto:jpm@cs.uu.nl" target="_blank">jpm@cs.uu.nl</a>&gt;</span> a écrit :<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi Yves,<br><br>GHC.Generics [1] and SYB [2] are two rather different approaches to generic programming. There are things that can be done in one but not in the other, and there are things that are easier on one rather than the other. For instance, SYB tends to be very useful for large AST transformations, with functions that have a general behaviour but a couple of particular cases for a few constructors. GHC.Generics, on the other hand, can encode functions such as generic fmap and traverse. It lends itself better to optimisation since it doesn&#39;t use runtime casts, and as such tends to be faster than SYB. It isn&#39;t planned to replace SYB.<br>





<br><br>Cheers,<br>Pedro<br><br>[1] <a href="http://www.haskell.org/haskellwiki/Generics" target="_blank">http://www.haskell.org/haskellwiki/Generics</a><br>[2] <a href="http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB" target="_blank">http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB</a><div>



<div><br>

<br><div class="gmail_quote">On Mon, Mar 12, 2012 at 16:35, Yves Parès <span dir="ltr">&lt;<a href="mailto:yves.pares@gmail.com" target="_blank">yves.pares@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





I&#39;d have a question concerning GHC.Generics: how does it relate to SYB&#39;s Data.Generics?<br>Is it intended to replace it or complete it?<br>In other words: does class Data.Generics.Data class do things that class GHC.Generics.Generic can&#39;t do?<br>







<br><br><div class="gmail_quote">Le 12 mars 2012 04:27, Reiner Pope <span dir="ltr">&lt;<a href="mailto:reiner.pope@gmail.com" target="_blank">reiner.pope@gmail.com</a>&gt;</span> a écrit :<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div><div>

<div style="word-wrap:break-word"><div>Hi all,</div><div><br></div>I&#39;ve been playing with GHC&#39;s new generics features (see <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html" target="_blank">http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html</a>). All the documentation I&#39;ve seen suggests creating a &quot;helper class&quot; -- for instance, the GSerialize class in the above link -- on which one defines generic instances. <div>







<br></div><div>It seems to me that this isn&#39;t necessary. For example, here&#39;s the the example from the GHC docs, but without a helper class:</div><div><br></div><div>&gt; -- set the phantom type of Rep to (), to avoid ambiguity</div>







<div>&gt; from0 :: Generic a =&gt; a -&gt; Rep a ()</div><div>&gt; from0 = from</div><div>&gt; </div><div>&gt; data Bit = O | I</div><div>&gt; </div><div>&gt; class Serialize a where</div><div>&gt;   put :: a -&gt; [Bit]</div>







<div>&gt; </div><div>&gt;   default put :: (Generic a, Serialize (Rep a ())) =&gt; a -&gt; [Bit]</div><div>&gt;   put = put . from0</div><div>&gt; </div><div>&gt; instance Serialize (U1 x) where</div><div>&gt;   put U1 = []</div>







<div>&gt; </div><div>&gt; instance (Serialize (a x), Serialize (b x)) =&gt; Serialize ((a :*: b) x) where</div><div>&gt;   put (x :*: y) = put x ++ put y</div><div>&gt; </div><div>&gt; instance (Serialize (a x), Serialize (b x)) =&gt; Serialize ((a :+: b) x) where</div>







<div>&gt;   put (L1 x) = O : put x</div><div>&gt;   put (R1 x) = I : put x</div><div>&gt; </div><div>&gt; instance (Serialize (a x)) =&gt; Serialize (M1 i c a x) where</div><div>&gt;   put (M1 x) = put x</div><div>&gt; </div>







<div>&gt; instance (Serialize a) =&gt; Serialize (K1 i a x) where</div><div>&gt;   put (K1 x) = put x</div><div><br></div><div>Is there a reason to prefer using helper classes? Or perhaps we should update the wiki page (<a href="http://www.haskell.org/haskellwiki/Generics" target="_blank">http://www.haskell.org/haskellwiki/Generics</a>) to avoid using helper classes?</div>







<div><br></div><div>Regards,</div><div>Reiner</div></div><br></div></div><div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></div></blockquote></div><br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>