+ 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 (ls :: [Either (Name, FixItem) (FastString, Located Fixity)]) =
+ 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
+bindLocalNamesFV_WithFixities :: [Name] -> UniqFM (Located Fixity) -> RnM (a, FreeVars) -> RnM (a, FreeVars)
+bindLocalNamesFV_WithFixities names fixities cont =
+ -- find the names that have fixity decls
+ let boundFixities = foldr
+ (\ name -> \ acc ->
+ -- check whether this name has a fixity decl
+ case lookupUFM fixities (occNameFS (nameOccName name)) of
+ Just (L _ fix) -> (name, FixItem (nameOccName name) fix) : acc
+ Nothing -> acc) [] names in
+ -- bind the names; extend the fixity env; do the thing inside
+ bindLocalNamesFV names (extendFixityEnv boundFixities cont)