Fix Trac #2985: generating superclasses and recursive dictionaries
[ghc-hetmet.git] / compiler / typecheck / TcRnTypes.lhs
index ff8e3d6..28bfd8e 100644 (file)
@@ -29,7 +29,7 @@ module TcRnTypes(
 
        -- Insts
        Inst(..), EqInstCo, InstOrigin(..), InstLoc(..), 
 
        -- Insts
        Inst(..), EqInstCo, InstOrigin(..), InstLoc(..), 
-       pprInstLoc, pprInstArising, instLocSpan, instLocOrigin,
+       pprInstLoc, pprInstArising, instLocSpan, instLocOrigin, setInstLoc,
        LIE, emptyLIE, unitLIE, plusLIE, consLIE, instLoc, instSpan,
        plusLIEs, mkLIE, isEmptyLIE, lieToList, listToLIE,
 
        LIE, emptyLIE, unitLIE, plusLIE, consLIE, instLoc, instSpan,
        plusLIEs, mkLIE, isEmptyLIE, lieToList, listToLIE,
 
@@ -868,6 +868,9 @@ data InstLoc = InstLoc InstOrigin SrcSpan ErrCtxt
 instLoc :: Inst -> InstLoc
 instLoc inst = tci_loc inst
 
 instLoc :: Inst -> InstLoc
 instLoc inst = tci_loc inst
 
+setInstLoc :: Inst -> InstLoc -> Inst
+setInstLoc inst new_loc = inst { tci_loc = new_loc }
+
 instSpan :: Inst -> SrcSpan
 instSpan wanted = instLocSpan (instLoc wanted)
 
 instSpan :: Inst -> SrcSpan
 instSpan wanted = instLocSpan (instLoc wanted)
 
@@ -912,7 +915,13 @@ data InstOrigin
   | ExprSigOrigin      -- e :: ty
   | RecordUpdOrigin
   | ViewPatOrigin
   | ExprSigOrigin      -- e :: ty
   | RecordUpdOrigin
   | ViewPatOrigin
+
   | InstScOrigin       -- Typechecking superclasses of an instance declaration
   | InstScOrigin       -- Typechecking superclasses of an instance declaration
+
+  | NoScOrigin          -- A very special hack; see TcSimplify,
+                       --   Note [Recursive instances and superclases]
+                          
+
   | DerivOrigin                -- Typechecking deriving
   | StandAloneDerivOrigin -- Typechecking stand-alone deriving
   | DefaultOrigin      -- Typechecking a default decl
   | DerivOrigin                -- Typechecking deriving
   | StandAloneDerivOrigin -- Typechecking stand-alone deriving
   | DefaultOrigin      -- Typechecking a default decl
@@ -936,6 +945,7 @@ instance Outputable InstOrigin where
     ppr TupleOrigin          = ptext (sLit "a tuple")
     ppr NegateOrigin         = ptext (sLit "a use of syntactic negation")
     ppr InstScOrigin         = ptext (sLit "the superclasses of an instance declaration")
     ppr TupleOrigin          = ptext (sLit "a tuple")
     ppr NegateOrigin         = ptext (sLit "a use of syntactic negation")
     ppr InstScOrigin         = ptext (sLit "the superclasses of an instance declaration")
+    ppr NoScOrigin            = ptext (sLit "an instance declaration")
     ppr DerivOrigin          = ptext (sLit "the 'deriving' clause of a data type declaration")
     ppr StandAloneDerivOrigin = ptext (sLit "a 'deriving' declaration")
     ppr DefaultOrigin        = ptext (sLit "a 'default' declaration")
     ppr DerivOrigin          = ptext (sLit "the 'deriving' clause of a data type declaration")
     ppr StandAloneDerivOrigin = ptext (sLit "a 'deriving' declaration")
     ppr DefaultOrigin        = ptext (sLit "a 'default' declaration")