X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcInstDcls.lhs;h=fc424813f7d2f8c4ab4bdc751f479c45ae751ed4;hb=befdf6ad2c5ede7a30f2aa31eeb506562928fbe0;hp=df43f53e3b6ff3c984b7d6ae0485a67f72d774c9;hpb=030ecd78112d9db9a83d156d431a993cbcd64eab;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcInstDcls.lhs b/compiler/typecheck/TcInstDcls.lhs index df43f53..fc42481 100644 --- a/compiler/typecheck/TcInstDcls.lhs +++ b/compiler/typecheck/TcInstDcls.lhs @@ -31,6 +31,7 @@ import TypeRep import DataCon import Class import Var +import Id import MkId import Name import NameSet @@ -87,9 +88,9 @@ $tau_iop$ is the tau type for this instance of a class method \item $alpha$ is the class variable \item -$LIE_cop' = LIE_cop [X gammas_bar / alpha, fresh betas_bar]$ +$LIE_cop' = LIE_cop [X gammas_bar \/ alpha, fresh betas_bar]$ \item -$tau_cop' = tau_cop [X gammas_bar / alpha, fresh betas_bar]$ +$tau_cop' = tau_cop [X gammas_bar \/ alpha, fresh betas_bar]$ \end{enumerate} ToDo: Update the list above with names actually in the code. @@ -97,7 +98,7 @@ ToDo: Update the list above with names actually in the code. \begin{enumerate} \item First, make the LIEs for the class and instance contexts, which means -instantiate $thetaC [X inst_tyvars / alpha ]$, yielding LIElistC' and LIEC', +instantiate $thetaC [X inst_tyvars \/ alpha ]$, yielding LIElistC' and LIEC', and make LIElistI and LIEI. \item Then process each method in turn. @@ -136,7 +137,7 @@ tcInstDecls1 -- Deal with both source-code and imported instance decls -> [LInstDecl Name] -- Source code instance decls -> [LDerivDecl Name] -- Source code stand-alone deriving decls -> TcM (TcGblEnv, -- The full inst env - [InstInfo], -- Source-code instance decls to process; + [InstInfo Name], -- Source-code instance decls to process; -- contains all dfuns for this module HsValBinds Name) -- Supporting bindings for derived instances @@ -215,7 +216,7 @@ assocInClassErr name = ptext (sLit "Associated type") <+> quotes (ppr name) <+> ptext (sLit "must be inside a class instance") -addInsts :: [InstInfo] -> TcM a -> TcM a +addInsts :: [InstInfo Name] -> TcM a -> TcM a addInsts infos thing_inside = tcExtendLocalInstEnv (map iSpec infos) thing_inside @@ -230,7 +231,7 @@ addFamInsts tycons thing_inside \begin{code} tcLocalInstDecl1 :: LInstDecl Name - -> TcM ([InstInfo], [TyThing]) -- [] if there was an error + -> TcM ([InstInfo Name], [TyThing]) -- [] if there was an error -- A source-file instance declaration -- Type-check all the stuff before the "where" -- @@ -238,7 +239,7 @@ tcLocalInstDecl1 :: LInstDecl Name tcLocalInstDecl1 (L loc (InstDecl poly_ty binds uprags ats)) = -- Prime error recovery, set source location recoverM (return ([], [])) $ - setSrcSpan loc $ + setSrcSpan loc $ addErrCtxt (instDeclCtxt1 poly_ty) $ do { is_boot <- tcIsHsBoot @@ -258,7 +259,8 @@ tcLocalInstDecl1 (L loc (InstDecl poly_ty binds uprags ats)) -- Finally, construct the Core representation of the instance. -- (This no longer includes the associated types.) - ; dfun_name <- newDFunName clas inst_tys loc + ; dfun_name <- newDFunName clas inst_tys (getLoc poly_ty) + -- Dfun location is that of instance *header* ; overlap_flag <- getOverlapFlag ; let (eq_theta,dict_theta) = partition isEqPred theta theta' = eq_theta ++ dict_theta @@ -371,7 +373,7 @@ tcLocalInstDecl1 (L loc (InstDecl poly_ty binds uprags ats)) %************************************************************************ \begin{code} -tcInstDecls2 :: [LTyClDecl Name] -> [InstInfo] +tcInstDecls2 :: [LTyClDecl Name] -> [InstInfo Name] -> TcM (LHsBinds Id, TcLclEnv) -- (a) From each class declaration, -- generate any default-method bindings @@ -457,7 +459,7 @@ is the @dfun_theta@ below. \begin{code} -tcInstDecl2 :: InstInfo -> TcM (LHsBinds Id) +tcInstDecl2 :: InstInfo Name -> TcM (LHsBinds Id) -- Returns a binding for the dfun ------------------------ @@ -582,7 +584,7 @@ tcInstDecl2 (InstInfo { iSpec = ispec, iBinds = VanillaInst monobinds uprags }) dfun_id = instanceDFunId ispec rigid_info = InstSkol inst_ty = idType dfun_id - loc = srcLocSpan (getSrcLoc dfun_id) + loc = getSrcSpan dfun_id in -- Prime error recovery recoverM (return emptyLHsBinds) $