-data NameMaker = NM (Located RdrName -> RnM Name)\r
-localNameMaker = NM (\name -> do [newname] <- newLocalsRn [name]\r
- return newname)\r
-\r
-topNameMaker = NM (\name -> do mod <- getModule\r
- newTopSrcBinder mod name)\r
-\r
-applyNameMaker :: NameMaker -> Located RdrName -> RnM Name\r
-applyNameMaker (NM f) x = f x\r
+data NameMaker = NM (forall a. Located RdrName -> (Name -> RnM (a, FreeVars))\r
+ -> RnM (a, FreeVars))\r
+\r
+matchNameMaker :: NameMaker\r
+matchNameMaker\r
+ = NM (\ rdr_name thing_inside -> \r
+ do { names@[name] <- newLocalsRn [rdr_name]\r
+ ; bindLocalNamesFV names $\r
+ warnUnusedMatches names $\r
+ thing_inside name })\r
+ \r
+topRecNameMaker, localRecNameMaker\r
+ :: UniqFM (Located Fixity) -- mini fixity env for the names we're about to bind\r
+ -- these fixities need to be brought into scope with the names\r
+ -> NameMaker\r
+\r
+-- topNameMaker and localBindMaker do not check for unused binding\r
+localRecNameMaker fix_env\r
+ = NM (\ rdr_name thing_inside -> \r
+ do { [name] <- newLocalsRn [rdr_name]\r
+ ; bindLocalNamesFV_WithFixities [name] fix_env $\r
+ thing_inside name })\r
+ \r
+topRecNameMaker fix_env\r
+ = NM (\rdr_name thing_inside -> \r
+ do { mod <- getModule\r
+ ; name <- newTopSrcBinder mod rdr_name\r
+ ; bindLocalNamesFV_WithFixities [name] fix_env $\r
+ thing_inside name })\r
+ -- Note: the bindLocalNamesFV_WithFixities is somewhat suspicious \r
+ -- because it binds a top-level name as a local name.\r
+ -- however, this binding seems to work, and it only exists for\r
+ -- the duration of the patterns and the continuation;\r
+ -- then the top-level name is added to the global env\r
+ -- before going on to the RHSes (see RnSource.lhs).\r
+\r
+applyNameMaker :: NameMaker -> Located RdrName\r
+ -> (Name -> RnM (a,FreeVars)) -> RnM (a, FreeVars)\r
+applyNameMaker (NM f) = f\r