functioanl dependencies bug

Iavor Diatchki diatchki@cse.ogi.edu
Mon, 05 May 2003 12:07:48 -0700


 > module Test where

Consider the following class declarations:

 > class C a b | a -> b
 > class C a b => D a

Given the way functional dependencies work at the moment,
Hugs should probably report an error that "b" is missing (this is what 
GHC does).
I don't really like this restriction (perhaps the determined parameters
could be automatically added?), but the current situation with Hugs
is very confusing... Here is what happens:

Given the following instance declarations:

 > instance C Int Bool
 > instance C Char Int
 > instance D Int

Hugs is happy, but if I swap the top two lines (the instances for C) it 
complains:
ERROR "bug3.lhs":18 - Cannot build superclass instance
*** Instance            : D Int
*** Context supplied    : ()
*** Required superclass : C Int Int

I am guessing, but I think "b" ends up being a free type variable, and 
instances are
processed from the bottom up (the ubiquitous stack?), so when I swap the 
declarations,
"b" gets bound to Int...

bye
iavor