[Haskell-cafe] Generic traversals for GADTs

Ozgur Akgun ozgurakgun at gmail.com
Sun Oct 31 17:39:59 EDT 2010


Café,

SYB-style libraries (and especially Uniplate) make it very easy to run
generic
traversals (queries/transformations) on ADTs.

> data Expr = ...
> x :: Expr
> f :: Expr -> Expr
> transform :: (Expr -> Expr) -> Expr -> Expr
> transform f x :: Expr -- applies f to x (and its children) in a bottom-up
manner

Uniplate is very powerful and doesn't require any hand written type-class
instances to get going reasonably efficiently.

I can simply re-implement the functionality of Uniplate myself, modulo
requiring hand-written instances. (I didn't want to go into that road, since
I
don't need it for this argument.)

I did this exercise, because I wanted to understand why we don't have
similar
generic traversal libraries for GADTs. And, it didn't take long :)
I can post my trials but they are really baby steps and they wouldn't be
helpful.

My question is:

Considering how useful generic traversal libraries and GADTs are, has
anybody
tried implementing a generic traversal library (like Uniplate or similar)
for
GADTs? Is it a hard (or impossible, or not efficient, or problematic in some
other way) thing to implement, or is it just not a requirement for anyone
else?

Best,
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101031/16aaa25d/attachment.html


More information about the Haskell-Cafe mailing list