never executed always true always false
    1 module GHC.Types.Fixity.Env
    2    ( FixityEnv
    3    , FixItem (..)
    4    , emptyFixityEnv
    5    , lookupFixity
    6    , mkIfaceFixCache
    7    , emptyIfaceFixCache
    8    )
    9 where
   10 
   11 import GHC.Prelude
   12 
   13 import GHC.Types.Fixity
   14 import GHC.Types.Name
   15 import GHC.Types.Name.Env
   16 
   17 import GHC.Utils.Outputable
   18 
   19 -- | Fixity environment mapping names to their fixities
   20 type FixityEnv = NameEnv FixItem
   21 
   22 -- | Fixity information for an 'Name'. We keep the OccName in the range
   23 -- so that we can generate an interface from it
   24 data FixItem = FixItem OccName Fixity
   25 
   26 instance Outputable FixItem where
   27   ppr (FixItem occ fix) = ppr fix <+> ppr occ
   28 
   29 emptyFixityEnv :: FixityEnv
   30 emptyFixityEnv = emptyNameEnv
   31 
   32 lookupFixity :: FixityEnv -> Name -> Fixity
   33 lookupFixity env n = case lookupNameEnv env n of
   34                         Just (FixItem _ fix) -> fix
   35                         Nothing         -> defaultFixity
   36 
   37 -- | Creates cached lookup for the 'mi_fix_fn' field of 'ModIface'
   38 mkIfaceFixCache :: [(OccName, Fixity)] -> OccName -> Maybe Fixity
   39 mkIfaceFixCache pairs
   40   = \n -> lookupOccEnv env n
   41   where
   42    env = mkOccEnv pairs
   43 
   44 emptyIfaceFixCache :: OccName -> Maybe Fixity
   45 emptyIfaceFixCache _ = Nothing
   46