[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] Class Synonyms
From: Stefan Holdermans <sholderm () students ! cs ! uu ! nl>
Date: 2004-12-11 8:55:51
Message-ID: 7594AAA0-4B52-11D9-91A0-000D934175F6 () students ! cs ! uu ! nl
[Download RAW message or body]
Jorge,
> 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.
Using -fallow-undecidable-instances (in GHC) you could do:
\begin{code}
class Foo a b | a -> b where
foo_method1 :: ...
foo_method2 :: ...
...
class (Foo a a) => Bar a where
instance (Foo a a) => Bar a where -- replaces all your other Bar
instances
instance Foo Integer Integer where
foo_method1 = ...
foo_method2 = ...
\end{code}
HTH,
Stefan
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic