Data.Generics vs. Template Haskell

I am trying to figure out where these two libraries stand in relation to each other and which one is preferred to do generic programming in Haskell. I understand that their goals often intersect but couldn't find any good comparisons. Could someone point me in the right direction? Thanks, - Slava Akhmechet

Hello Vyacheslav, Thursday, August 24, 2006, 11:51:46 PM, you wrote:
I am trying to figure out where these two libraries stand in relation to each other and which one is preferred to do generic programming in Haskell. I understand that their goals often intersect but couldn't find any good comparisons. Could someone point me in the right direction?
search for "generics" on hswiki, you should find a lot of papers. in particular, there is a new paper that compares many different approaches to generic programming. in particular, TH is not g.p. tools, it's just a universal Haskell code generator whcih can be used to solve particular tasks in this area. but to solve general problem of defining traversal function what has some general case and a nu,ber of type-specific cases TH is not very appropriate TH (and DriFT) are widely used to generate instances like the haskell compiler itself generates instances for Eq/Show/... and TH, unlike many g.p. tools does it at compile-time. using TH, you also get access to field/constructor names summary: if your task fits into the features provided by g.p. tools, you will gain a much time using them. if your task need compile-time code generation (so that generic program will be no slower than hand-written one) or you need some advanced features which your g.p. tool doesn't provide - welcome to TH with all its programming oddities. development of TH routines for g.p. is an order of magnitude slower (at least!) than doing the same with specialized tool -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Bulat Ziganshin wrote:
Hello Vyacheslav,
Thursday, August 24, 2006, 11:51:46 PM, you wrote:
I am trying to figure out where these two libraries stand in relation to each other and which one is preferred to do generic programming in Haskell. I understand that their goals often intersect but couldn't find any good comparisons. Could someone point me in the right direction?
summary: if your task fits into the features provided by g.p. tools, you will gain a much time using them. if your task need compile-time code generation (so that generic program will be no slower than hand-written one) or you need some advanced features which your g.p. tool doesn't provide - welcome to TH with all its programming oddities. development of TH routines for g.p. is an order of magnitude slower (at least!) than doing the same with specialized tool
TH and generics can be synergistic: Generics reduce the amount of code you need to write to add new cases compared to more verbose techniques, and TH can automate writing some of the remaining boilerplate code.

On Fri, 2006-08-25 at 00:53 +0400, Bulat Ziganshin wrote:
Hello Vyacheslav,
Thursday, August 24, 2006, 11:51:46 PM, you wrote:
I am trying to figure out where these two libraries stand in relation to each other and which one is preferred to do generic programming in Haskell. I understand that their goals often intersect but couldn't find any good comparisons. Could someone point me in the right direction?
search for "generics" on hswiki, you should find a lot of papers. in particular, there is a new paper that compares many different approaches to generic programming. in particular, TH is not g.p. tools, it's just a universal Haskell code generator whcih can be used to solve particular tasks in this area. but to solve general problem of defining traversal function what has some general case and a nu,ber of type-specific cases TH is not very appropriate
AFAIK this problem is now fully solved by Barry Jay: polyadic traversal drops out of pattern calculus. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net
participants (4)
-
Bulat Ziganshin
-
Chris Kuklewicz
-
skaller
-
Vyacheslav Akhmechet