[project @ 2000-03-06 10:12:57 by sewardj]
authorsewardj <unknown>
Mon, 6 Mar 2000 10:12:57 +0000 (10:12 +0000)
committersewardj <unknown>
Mon, 6 Mar 2000 10:12:57 +0000 (10:12 +0000)
typeInstDefn(), the bit which invents GHC compatible instance names:
handle multiparam type classes.  This enables Hugs standalone to deal
multiparam type classes, but there's a fudge:

   class Foo s m where { }
   instance Foo s () where { }

GHC calls the instance $fFoos.  But Hugs records type vars as offsets,
and loses the name "s" in the instance head; all it knows about
are tyvar numbers (offsets), starting from zero.  So it can never
generate $fFoos here, only $fFoo0 (zero).  The resulting code works
in standalone mode but will not interwork with GHC.  In general tho,
multiparam type classes are not (yet) supported in combined mode;
interface.c certainly can't handle them.

It might be simplest in this case to change GHC's instance naming
defn to be the same as Hugs'.

ghc/interpreter/type.c

index fec44e1..645ffb5 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: type.c,v $
- * $Revision: 1.24 $
- * $Date: 2000/03/06 08:38:05 $
+ * $Revision: 1.25 $
+ * $Date: 2000/03/06 10:12:57 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -1983,12 +1983,13 @@ Inst in; {                              /* member functions for instance in*/
        for (j = 0; i<FILENAME_MAX && str[j]!='\0'; i++, j++) {
           buf[i] = str[j];
        }
-       for (; nonNull(pp); pp=tl(pp)) {
+       if (nonNull(pp)) {
           qq = hd(pp);
           while (isAp(qq)) qq = fun(qq);
           switch (whatIs(qq)) {
-             case TYCON: str = textToStr(tycon(qq).text); break;
-             case TUPLE: str = textToStr(ghcTupleText(qq)); break;
+             case TYCON:  str = textToStr(tycon(qq).text); break;
+             case TUPLE:  str = textToStr(ghcTupleText(qq)); break;
+             case OFFSET: sprintf(str,"%d",offsetOf(qq)); break;
              default: internal("typeInstDefn: making GHC name"); break;
           }
           for (j = 0; i<FILENAME_MAX && str[j]!='\0'; i++, j++) {