[Haskell-cafe] looking for examples of non-full Functional Dependencies

Iavor Diatchki iavor.diatchki at gmail.com
Thu Apr 17 13:09:08 EDT 2008


On Wed, Apr 16, 2008 at 11:06 PM, Martin Sulzmann
<martin.sulzmann at gmail.com> wrote:
>  3) Multi-range FDs
>  Consider
>  class C a b c | a -> b c
>  instance C a b b => C [a] [b] [b]
>  This time it's straightforward.
>  C [x] y z yields the improvement y = [b] and z = [b]
>  which then allows us to apply the instance.

I don't think that this improvement rule is justified (unless there
are some assumptions that are added to the system that go beyond FD?).
  By the way, note that the above example does not have any instances
for C, so lets first add a base case like this:

instance C Char Bool Bool

Now the instances for C are: { C Char Bool Bool, C [Char] [Bool]
[Bool], ... }.  Certainly, if you just consider these instances, then
the improvement rule that you suggest is valid.  However, suppose that
we also add the instance:

instance C [Int] Char Bool

Note that this instance does not violate the FD: if we know the first
argument, then we know exactly what are the other two arguments.  In
this context, it is not OK to improve C [x] y z as you suggest because
'x' may be instantiate to 'Int'.


More information about the Haskell-Cafe mailing list