Hi.
Christopher Howard писал 21.12.2012 14:27:
instance (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (Socket4
a b
c d) where
mempty = Socket4 mempty mempty mempty mempty
Socket4 a b c d `mappend` Socket4 w x y z =
Socket4 (a `mappend` w) (b `mappend` x) (c `mappend` y) (d
`mappend` z)
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.)
Something like
data a ::: b = a ::: b
infixl 5 :::
instance (Monoid a, Monoid b) => Monoid (a ::: b) where ...
So, Monoid instance for, say, (a ::: b ::: c) == ((a ::: b) ::: c) will
(should) be inferred automatically.
WBR, Ilya Portnov
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe