On Fri, Dec 21, 2012 at 9:27 AM, Christopher Howard wrote:
Thank you for your help. An additional question, if I might: For thesake of elegance and simplicity, I modified the class and instances to
avoid the "tuple" aspect:
data Socket2 a b = Socket2 a b
instance (Monoid a, Monoid b) => Monoid (Socket2 a b) where
Of course, I thought it would be likely I would want other classes and
instances with additional numbers of types:
data Socket3 a b c = Socket3 a b c
instance (Monoid a, Monoid b, Monoid c) => Monoid (Socket3 a b c) where
data Socket4 a b c d = Socket4 a b c d
instance (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (Socket4 a b
data Socket 5 a b c d e... et cetera
--------
Seeing as the pattern here is so rigid and obvious, I was wondering: is
it possible to abstract this even more? So I could, for instance, just
specify that I want a Socket with 8 types, and poof, it would be there?
Or is this as meta as we get? (I.e., without going to something like
Template Haskell.)