Klaus Ostermann schrieb:
> data SimpleExp = Num Int | Add SimpleExp SimpleExp
> 
> data LabelledExp = LNum Int String | LAdd LabelledExp LabelledExp String
> 
> I wonder what would be the best way to model this situation without
> repeating the structure of the AST.

How about the following simple parameterization?

data Exp label = LNum Int label
               | LAdd (Exp label) (Exp label) label

type SimpleExp = Exp ()

mkNum i = LNum i ()

type LabelledExp = Exp String

Cheers Christian

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to