[Haskell-cafe] Class Synonyms

Stefan Holdermans sholderm at students.cs.uu.nl
Sat Dec 11 03:55:51 EST 2004


> 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:

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 

instance Foo Integer Integer where
   foo_method1 = ...
   foo_method2 = ...



More information about the Haskell-Cafe mailing list