<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hello,<br><br>Say I have a certain type for parse trees:<br>data Expr = Var String</div>   | Enclosed String Expr String<br>   | Prefix Expr Expr<br>   | Ternary Expr String Expr String Expr<br>   deriving (Show,Eq,Ord,Generic)--,Typeable)<br><div><br>Then I want a new type where every occurence of "Expr" definition changed to "[Expr]":<br>data ExprL = VarL String<br></div>   | EnclosedL String [Expr] String<br>   | PrefixL [Expr] [Expr]<br>   | TernaryL [Expr] String [Expr] String [Expr]<br>   deriving (Show,Eq,Ord,Generic)<br><div><br>Sometimes, I also want to use a DList instead of list.<br></div>data ExprD = VarD String<br>   | EnclosedD String (DList Expr) String<br>   | PrefixD (DList Expr) (DList Expr)<br>   | TernaryD (DList Expr) String (DList Expr) String (DList Expr)<br>   deriving (Show,Eq,Ord,Generic)<br><div><br>They have exactly the same structure, is there a way to unify the three definitions into one?<br>Furthurmore, is it possible to generalise the latter two for all Functors ?<br><br>Thanks,<br>ducis<br></div></div>