[Haskell-cafe] Variants of a recursive data structure

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Aug 3 09:40:11 EDT 2006

Hello Klaus,

Thursday, August 3, 2006, 2:51:01 PM, you wrote:

> data SimpleExp = Num Int | Add SimpleExp SimpleExp

> data LabelledExp = LNum Int String | LAdd LabelledExp LabelledExp String

> The icing on the cake would be if it would also be possible to have a
> function

> unlabel :: LabeledExp -> Exp

> that does *not* need to know about the full structure of expressions.

> So, what options do I have to address this problem in Haskell?

Template Haskell (compile-time code generator) can be used to
automatically generate unlabel and SimpleExp from the LabelledExp
definition. you can also see to other generic programming solutions
which was overviewed in

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list