[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: [Haskell-cafe] Class Synonyms
From: Jorge Adriano Aires <jadrian () mat ! uc ! pt>
Date: 2004-12-11 1:40:03
Message-ID: 200412110140.03349.jadrian () mat ! uc ! pt
[Download RAW message or body]
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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic