
Hello I imagine that I have two types A and B I want to create a ADT data C = C A B 1) the toGsl class class ToGsl a where toGsl :: a -> [Double] this class allow to convert a type to a Vector of double in order to use gsl for a fit so I can create instance for A and B (I do not write the instance but the result of the toGsl function) A -> [a1, ... an] B -> [b1, ... bm] Now I want this to work also with C C -> [a1..., an] ++ [b1, .... bm] So the C instance is juste the (toGsl a) ++ (toGsl b) Is there a way to write this generically for other type construct like (data D = D C A) etc.... Functor, Applicative, Monoid ? 2) the fromGsl case now the inverse method is cladd FromGsl a where fromGsl :: a -> [Double] -> a so now the question is if I have a [Double], I need t osplit this list for each composant of the ADT. in the case of C fromGSL (C a b) v = ...split the vector... and apply fromGsl to a and b So my question is the symetic of the previous one. Is it possible to create a generic function inorder to do this. thanks for your help. Frederic