-bindLocalFixities :: [FixitySig RdrName] -> (UniqFM (Located Fixity) -> RnM a) -> RnM a
--- Used for nested fixity decls:
--- bind the names that are in scope already;
--- pass the rest to the continuation for later
--- as a FastString->(Located Fixity) map
---
--- No need to worry about type constructors here,
--- Should check for duplicates?
-bindLocalFixities fixes thing_inside
- | 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 (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
+type MiniFixityEnv = FastStringEnv (Located Fixity)
+ -- Mini fixity env for the names we're about
+ -- to bind, in a single binding group
+ --
+ -- It is keyed by the *FastString*, not the *OccName*, because
+ -- the single fixity decl infix 3 T
+ -- affects both the data constructor T and the type constrctor T
+ --
+ -- We keep the location so that if we find
+ -- a duplicate, we can report it sensibly