:kind feature request in ghci

Benjamin Franksen benjamin.franksen at bessy.de
Sun Mar 28 20:56:22 EST 2004

On Saturday 27 March 2004 16:33, S. Alexander Jacobson wrote:
> Alternatively, is there another way to
> figure out how to create an instance of
> a class like this?
>     class MyClass a b where emptyVal::a b
> Here are one of the thing that don't work:
>     type MyType a = [a]
>     instance MyClass (MyType a) a where emptyVal=[]
> And I have no idea why...

Well, you've been told why.

Anyway, why do you insist on using a two parameter type class? The more

	class MyClass a where emptyVal::a

would do exactly the same. To make type constructor B applied to type C an
instance you just write

	instance MyClass (B C) where ...

for instance

	instance MyClass [a] where emptyVal=[]

If you enable overlapping instances you could even add

	instance MyClass [Int] where emptyVal=[0]

The only difference to your 2-parameter class is that now you can declare
instances for simple types like Integer too. Is that a problem?


More information about the Glasgow-haskell-users mailing list