From: simonpj Date: Thu, 28 Jan 1999 16:37:42 +0000 (+0000) Subject: [project @ 1999-01-28 16:37:41 by simonpj] X-Git-Tag: Approximately_9120_patches~6658 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ddc68ccc4c2efacf152b166cc40a0a592f90e399;p=ghc-hetmet.git [project @ 1999-01-28 16:37:41 by simonpj] Add OccName.mkMethodOcc, whose absence broke nofib/spectral/fft2 --- diff --git a/ghc/compiler/basicTypes/OccName.lhs b/ghc/compiler/basicTypes/OccName.lhs index cba9b4f..834134f 100644 --- a/ghc/compiler/basicTypes/OccName.lhs +++ b/ghc/compiler/basicTypes/OccName.lhs @@ -394,13 +394,12 @@ mk_deriv occ_sp sys_prefix str = mkSysOcc occ_sp (encode sys_prefix ++ str) \end{code} \begin{code} -mkDictOcc, mkWorkerOcc, mkMethodOcc, mkDefaultMethodOcc, +mkDictOcc, mkWorkerOcc, mkDefaultMethodOcc, mkClassTyConOcc, mkClassDataConOcc, mkSpecOcc :: OccName -> OccName -- These derived variables have a prefix that no Haskell value could have mkWorkerOcc = mk_simple_deriv varName "$w" -mkMethodOcc = mk_simple_deriv varName "$m" mkDefaultMethodOcc = mk_simple_deriv varName "$dm" mkClassTyConOcc = mk_simple_deriv tcName ":T" -- The : prefix makes sure it classifies mkClassDataConOcc = mk_simple_deriv dataName ":D" -- as a tycon/datacon @@ -437,6 +436,31 @@ mkDFunOcc cls_occ tycon_occ index | otherwise = show index \end{code} +We used to add a '$m' to indicate a method, but that gives rise to bad +error messages from the type checker when we print the function name or pattern +of an instance-decl binding. Why? Because the binding is zapped +to use the method name in place of the selector name. +(See TcClassDcl.tcMethodBind) + +The way it is now, -ddump-xx output may look confusing, but +you can always say -dppr-debug to get the uniques. + +However, we *do* have to zap the first character to be lower case, +because overloaded constructors (blarg) generate methods too. +And convert to VarName space + +e.g. a call to constructor MkFoo where + data (Ord a) => Foo a = MkFoo a + +If this is necessary, we do it by prefixing '$m'. These +guys never show up in error messages. What a hack. + +\begin{code} +mkMethodOcc :: OccName -> OccName +mkMethodOcc occ@(OccName VarName fs) = occ +mkMethodOcc occ = mk_simple_deriv varName "$m" +\end{code} + %************************************************************************ %* * diff --git a/ghc/compiler/typecheck/Inst.lhs b/ghc/compiler/typecheck/Inst.lhs index 63d0433..af113be 100644 --- a/ghc/compiler/typecheck/Inst.lhs +++ b/ghc/compiler/typecheck/Inst.lhs @@ -377,13 +377,7 @@ instToIdBndr (Dict u clas ty orig loc) = mkUserLocal (mkDictOcc (getOccName clas)) u (mkDictTy clas ty) loc instToIdBndr (Method u id tys theta tau orig loc) - = mkUserLocal (getOccName id) u tau loc - -- We used to call mkMethodOcc here, but that gives rise to bad - -- error messages when we print the function name or pattern - -- of an instance-decl binding. Why? Because the binding is zapped - -- to use the method name in place of the selector name. - -- The way it is now, -ddump-xx output may look confusing, but - -- you can always say -dppr-debug to get the uniques + = mkUserLocal (mkMethodOcc (getOccName id)) u tau loc instToIdBndr (LitInst u list ty orig loc) = mkSysLocal SLIT("lit") u ty