From haskell-cafe Sat Dec 11 01:40:03 2004 From: Jorge Adriano Aires Date: Sat, 11 Dec 2004 01:40:03 +0000 To: haskell-cafe Subject: [Haskell-cafe] Class Synonyms Message-Id: <200412110140.03349.jadrian () mat ! uc ! pt> X-MARC-Message: https://marc.info/?l=haskell-cafe&m=120491990139004 Hello! I got a multi-parameter type class: > class Foo a b | a -> b where > foo_method1 :: ... > foo_method2 :: ... > ... And some particular cases are important on their own, like the one where 'a' and 'b' are the same, I call elements with this property, Bar. So I defined: class Foo a a => Bar a where This is nice, now I can replace (F a a) for (Bar a) in the context of many functions. Less typing and it's more readable. Still, I have to define instances as: > instance Foo A A where > foo_method1 = bla1 > foo_method2 = bla2 > > instance Bar A where I'd like to achieve something better than this. I was looking for something like "class synonyms". So if I declared an instance Foo A A, I automagicaly had Bar A, because they'd be the same. Or even better, I could declare > instance Bar A where > foo_method1 = bla1 > foo_method2 = bla2 Is anything like this possible at all? Thanks, J.A.