[Haskell-cafe] Re: Problem with fundeps.

karczma at info.unicaen.fr karczma at info.unicaen.fr
Sun Jan 2 17:26:00 EST 2005


Ashley Yakeley writes: 

> GHCi is correct to complain: 
> 
>> class Vspace a v | v -> a
> 
> OK, the first parameter ("a") depends on the second ("v").

This is what I want. For a given set of vectors, the associated
scalars are unique, otherwise I would have problems with norm.
But I have problems anyway... 

> 
>> instance Vspace a a where
> 
> And this determines it: the first parameter must always be the same as 
> the second. 
> 
>> instance (Vspace a v) => Vspace a (c->v) where
> 
> This is incompatible with the previous instance declaration, since "a" 
> is not the same as "c -> v". 

Why "always the same"? This is just *this* instance. 

If I eliminate Vspace a a, and I write 

instance (Num a)=>Vspace a (c->a) where
 (f <+> g) x = f x + g x
 (a *> f) x = a * f x 

and then I tried to generalize, by 

instance (Vspace a v) => Vspace a (c->v) where
 (f <+> g) x = f x <+> g x
 -- ... 

I get another error, even less understandable. Can you
guess it without testing?... 

I permitted all extensions, overlapping instances, etc. 


Jerzy Karczmarczuk 



More information about the Haskell-Cafe mailing list