
On Sun, 2 Jan 2005 karczma@info.unicaen.fr wrote:
I am afraid that something is wrong with my understanding of multi- param classes with dependencies. I tried to generalize one of my old packages for quantum *abstract* computations, where state vectors are defined as functional objects, whose codomain has some arithmetic. It is easy to see that you can define (f <+> g) = \x -> f x + g x etc. It should be possible to curry this further, so I defined
class Vspace a v | v -> a where (<+>) :: v -> v -> v (*>) :: a -> v -> v -- etc.
instance Vspace a a where (<+>) = (+) (*>) = (*) -- etc. No problem.
instance (Vspace a v) => Vspace a (c->v) where f <+> g = \x -> f x <+> g x (a *> f) x = a *> (f x) -- ...
I had the same problem with the same class http://www.haskell.org//pipermail/haskell-cafe/2004-March/005979.html and thus Dylan Thurston advised me to drop functional dependencies. Here are two implementations using multi-type classes without functional dependencies. (They wait for unification, yet, sorry.) http://cvs.haskell.org/darcs/numericprelude/VectorSpace.lhs http://cvs.haskell.org/darcs/numericprelude/physunit/VectorSpace.hs