module GHC.Types.Fixity.Env
( FixityEnv
, FixItem (..)
, emptyFixityEnv
, lookupFixity
, mkIfaceFixCache
, emptyIfaceFixCache
)
where
import GHC.Prelude
import GHC.Types.Fixity
import GHC.Types.Name
import GHC.Types.Name.Env
import GHC.Utils.Outputable
type FixityEnv = NameEnv FixItem
data FixItem = FixItem OccName Fixity
instance Outputable FixItem where
ppr (FixItem occ fix) = ppr fix <+> ppr occ
emptyFixityEnv :: FixityEnv
emptyFixityEnv = emptyNameEnv
lookupFixity :: FixityEnv -> Name -> Fixity
lookupFixity env n = case lookupNameEnv env n of
Just (FixItem _ fix) -> fix
Nothing -> defaultFixity
mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Maybe Fixity
mkIfaceFixCache pairs
= \n -> lookupOccEnv env n
where
env = mkOccEnv pairs
emptyIfaceFixCache :: OccName -> Maybe Fixity
emptyIfaceFixCache _ = Nothing