functional dependencies
Ashley Yakeley
ashley@semantic.org
Wed, 24 Jul 2002 03:05:06 -0700
At 2002-07-23 09:06, Simon Peyton-Jones wrote:
>Dead right! Imagine there was a method in class D:
>
> class C a b => D a where
> op :: a -> b
>
>The type of 'op' is
>
> op :: D a => a -> b
>
>You can't really expect that the 'b' here is determined by 'a'!
Agreed. If you were going to allow "D a", they would have to be
considered different "b"s.
>Still, I suppose that if the methods in class D mention
>only 'a', then it is strange to require D to be parameterised over
>'b'. Thus, this seems more reasonable:
>
> class C a b => D a where
> op :: a -> a
>
>Even this seems odd, because we would get the deduction
>
> D a |- C a b
>
>(i.e. from a (D a) dictionary you can get a (C a b) dictionary)
>and that's only true for a particular 'b'.
Well that's OK. From a (D a) dictionary, you get a (C a b) dictionary,
where you're given "a", and you can find "b" from the fundep.
--
Ashley Yakeley, Seattle WA