data HNil = HNil; data HCons e l = HCons e l; class HList l where {} instance HList HNil where {} instance HList l => HList (HCons e l) where {} class HAppendC l l' where { type HAppend l l'; hAppend :: l -> l' -> HAppend l l'; } instance HList l => HAppendC HNil l where { type HAppend HNil l = l; hAppend x l = l; } instance HList l, HAppendC l l' => HAppendC (HCons x l) l' where { type HAppend (HCons x l) l' = HCons x (HAppend l l'); hAppend y l' = case y of HCons x l -> HCons x (hAppend l l');; } list1 = HCons 42 (HCons True HNil); list2 = HCons (1,0) (HCons False (HCons (\x -> x + 1) HNil)); main = hAppend list1 list2;