+ | null fixes = thing_inside emptyUFM
+ | otherwise = do ls <- mappM rn_sig fixes
+ let (now, later) = nowAndLater ls
+ extendFixityEnv now $ thing_inside later
+ where
+ rn_sig (FixitySig lv@(L loc v) fix) = do
+ vopt <- lookupBndrRn_maybe v
+ case vopt of
+ Just new_v -> returnM (Left (new_v, (FixItem (rdrNameOcc v) fix)))
+ Nothing -> returnM (Right (occNameFS $ rdrNameOcc v, (L loc fix)))
+
+ nowAndLater :: [Either (Name, FixItem) (FastString, Located Fixity)]
+ -> ([(Name,FixItem)], UniqFM (Located Fixity))
+ nowAndLater ls =
+ foldr (\ cur -> \ (now, later) ->
+ case cur of
+ Left (n, f) -> ((n, f) : now, later)
+ Right (fs, f) -> (now, addToUFM later fs f))
+ ([], emptyUFM) ls
+
+-- Used for nested fixity decls to bind names along with their fixities.
+-- the fixities are given as a UFM from an OccName's FastString to a fixity decl
+-- Also check for unused binders
+bindLocalNamesFV_WithFixities :: [Name]
+ -> MiniFixityEnv
+ -> RnM (a, FreeVars) -> RnM (a, FreeVars)
+bindLocalNamesFV_WithFixities names fixities thing_inside
+ = bindLocalNamesFV names $
+ extendFixityEnv boundFixities $
+ thing_inside