X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcInstDcls.lhs;h=0b4f8b028520291f6638a36698bc094a12ab0a88;hb=046ee54f048ddd721dcee41916d6a6f68db3b15b;hp=3236b6715121085b17badc1fb0864336c60ca130;hpb=3ad8f84f6a75f240383e62a14472d14eb372dcd1;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcInstDcls.lhs b/compiler/typecheck/TcInstDcls.lhs index 3236b67..0b4f8b0 100644 --- a/compiler/typecheck/TcInstDcls.lhs +++ b/compiler/typecheck/TcInstDcls.lhs @@ -24,7 +24,7 @@ import Inst ( newDictBndr, newDictBndrs, instToId, showLIE, getOverlapFlag, tcExtendLocalInstEnv ) import InstEnv ( mkLocalInstance, instanceDFunId ) import FamInst ( tcExtendLocalFamInstEnv ) -import FamInstEnv ( extractFamInsts ) +import FamInstEnv ( mkLocalFamInst ) import TcDeriv ( tcDeriving ) import TcEnv ( InstInfo(..), InstBindings(..), newDFunName, tcExtendIdEnv, tcExtendGlobalEnv @@ -179,16 +179,19 @@ tcInstDecls1 tycl_decls inst_decls deriv_decls -- (3) Instances from generic class declarations ; generic_inst_info <- getGenericInstances clas_decls - -- (3) Compute instances from "deriving" clauses; - -- This stuff computes a context for the derived instance decl, so it - -- needs to know about all the instances possible; hence inst_env4 - tcDeriving tycl_decls `thenM` \ (deriv_inst_info, deriv_binds) -> - addInsts deriv_inst_info $ + -- Next, construct the instance environment so far, consisting + -- of + -- a) local instance decls + -- b) generic instances + -- c) local family instance decls + ; addInsts local_info $ do { + ; addInsts generic_inst_info $ do { + ; addFamInsts at_idx_tycon $ do { -- (4) Compute instances from "deriving" clauses; -- This stuff computes a context for the derived instance -- decl, so it needs to know about all the instances possible - ; (deriv_inst_info, deriv_binds) <- tcDeriving tycl_decls + ; (deriv_inst_info, deriv_binds) <- tcDeriving tycl_decls deriv_decls ; addInsts deriv_inst_info $ do { ; gbl_env <- getGblEnv @@ -224,7 +227,11 @@ addInsts infos thing_inside addFamInsts :: [TyThing] -> TcM a -> TcM a addFamInsts tycons thing_inside - = tcExtendLocalFamInstEnv (extractFamInsts tycons) thing_inside + = tcExtendLocalFamInstEnv (map mkLocalFamInstTyThing tycons) thing_inside + where + mkLocalFamInstTyThing (ATyCon tycon) = mkLocalFamInst tycon + mkLocalFamInstTyThing tything = pprPanic "TcInstDcls.addFamInsts" + (ppr tything) \end{code} \begin{code}