import HsSyn ( HsDecl, FixityDecl, Fixity, InstDecl,
Sig, HsBinds(..), Bind(..), MonoBinds(..),
GRHSsAndBinds, Match, HsExpr, HsLit, InPat,
- ArithSeqInfo, Fake, HsType
+ ArithSeqInfo, Fake, HsType,
+ collectMonoBinders
)
import HsPragmas ( InstancePragmas(..) )
import RdrHsSyn ( RdrName, SYN_IE(RdrNameMonoBinds) )
import TcSimplify ( tcSimplifyThetas )
import RnBinds ( rnMethodBinds, rnTopMonoBinds )
-import RnEnv ( newDfunName )
+import RnEnv ( newDfunName, bindLocatedLocalsRn )
import RnMonad ( SYN_IE(RnM), RnDown, GDown, SDown, RnNameSupply(..),
setNameSupplyRn, renameSourceCode, thenRn, mapRn, returnRn )
import Outputable ( Outputable(..){-instances e.g., (,)-} )
import PprType ( GenType, GenTyVar, GenClass, TyCon )
import PprStyle ( PprStyle(..) )
-import Pretty ( ppAbove, ppAboves, ppCat, ppBesides, ppStr, ppHang, SYN_IE(Pretty) )
+import Pretty ( ppAbove, ppAboves, ppCat, ppBesides,
+ ppPStr, ppStr, ppChar, ppHang, SYN_IE(Pretty) )
--import Pretty--ToDo:rm
--import FiniteMap--ToDo:rm
import SrcLoc ( mkGeneratedSrcLoc, SrcLoc )
import TyVar ( GenTyVar )
import UniqFM ( emptyUFM )
import Unique -- Keys stuff
+import Bag ( bagToList )
import Util ( zipWithEqual, zipEqual, sortLt, removeDups, assoc,
thenCmp, cmpList, panic, panic#, pprPanic, pprPanic#,
assertPanic-- , pprTrace{-ToDo:rm-}
extra_mbind_list = map gen_tag_n_con_monobind nm_alist_etc
extra_mbinds = foldr AndMonoBinds EmptyMonoBinds extra_mbind_list
method_binds_s = map gen_bind new_inst_infos
+ mbinders = bagToList (collectMonoBinders extra_mbinds)
-- Rename to get RenamedBinds.
-- The only tricky bit is that the extra_binds must scope over the
-- method bindings for the instances.
(dfun_names_w_method_binds, rn_extra_binds)
= renameSourceCode modname rn_name_supply (
+ bindLocatedLocalsRn "deriving" mbinders $ \ _ ->
rnTopMonoBinds extra_mbinds [] `thenRn` \ rn_extra_binds ->
mapRn rn_one method_binds_s `thenRn` \ dfun_names_w_method_binds ->
returnRn (dfun_names_w_method_binds, rn_extra_binds)
)
- rn_one meth_binds = newDfunName mkGeneratedSrcLoc `thenRn` \ dfun_name ->
- rnMethodBinds meth_binds `thenRn` \ rn_meth_binds ->
+ rn_one meth_binds = newDfunName Nothing mkGeneratedSrcLoc `thenRn` \ dfun_name ->
+ rnMethodBinds meth_binds `thenRn` \ rn_meth_binds ->
returnRn (dfun_name, rn_meth_binds)
in
derivingThingErr :: String -> TyCon -> Error
derivingThingErr thing tycon sty
- = ppHang (ppCat [ppStr "Can't make a derived instance of", ppStr thing])
- 4 (ppBesides [ppStr "for the type `", ppr sty tycon, ppStr "'"])
+ = ppHang (ppCat [ppPStr SLIT("Can't make a derived instance of"), ppStr thing])
+ 4 (ppBesides [ppPStr SLIT("for the type `"), ppr sty tycon, ppChar '\''])
\end{code}