Problem with functional dependencies
Marcin 'Qrczak' Kowalczyk
21 Dec 2000 10:05:14 GMT
Thu, 21 Dec 2000 00:59:29 -0800, Jeffrey R. Lewis <firstname.lastname@example.org> pisze:
> > class HasFoo a b | a -> b where
> > f :: HasFoo Int b => Int -> b
> > f x = foo x
> This is the step where the reasoning goes wrong. The functional
> dependency tells you that `b' isn't really a free variable, since
> it is dependent on `a'. If you substitute for `a', you can't expect
> `b' to remain unconstrained.
It's not unconstrained: the constraint is "HasFoo Int b", as written.
IMHO it should not matter that the constraint fully determines b.
> Asimilar situation arises if you try to declare an instance `HasFoo
> Int b', but in this case, hugs complains that the instance is more
> general than the dependency allows.
ghc does not complain. How would I express "the instance can be chosen
basing on 'a' alone, and the instance found will tell what constraints
are on 'b'"?
Aren't fundeps a too general mechanism which is not able to express
simpler statements? :-(
__("< Marcin Kowalczyk * email@example.com http://qrczak.ids.net.pl/
^^ SYGNATURA ZASTĘPCZA