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