[Haskell-cafe] Re: Problem with fundeps.
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Sun Jan 2 18:00:28 EST 2005
karczma at info.unicaen.fr writes:
> This is what I want. For a given set of vectors, the associated
> scalars are unique, otherwise I would have problems with norm.
In the instance Vspace a a the compiler doesn't know that "a" is
supposed to be a scalar only. It matches vector types (functions) too.
And adding a context won't help. An instance of the form
instance Ctx a => Cls (T a)
means "T a can always be used as an instance of Cls, and such usage
will yield a further requirement of Ctx a which must be fulfilled"
rather than "T a can be used as an instance of Cls as long as Ctx a
holds". In particular it will overlap with any other instance whose
head can be unified with Cls (T a). Instance overlapping doesn't take
instance contexts into account, only instance heads.
The problem can be "solved" by enumerating concrete scalar types
instead of using a generic instance Vspace a a. I'm afraid Haskell
classes are not expressive enough for a generic instance in this case.
--
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
More information about the Haskell-Cafe
mailing list