Keep the original name for non-exported record selectors and class
methods.
-- Predicates
omitIfaceSigForId,
-- Predicates
omitIfaceSigForId,
externallyVisibleId,
idFreeTyVars,
externallyVisibleId,
idFreeTyVars,
-- the instance decl
other -> False -- Don't omit!
-- the instance decl
other -> False -- Don't omit!
+
+-- Certain names must be exported with their original occ names, because
+-- these names are bound by either a class declaration or a data declaration
+-- or an explicit user export.
+exportWithOrigOccName :: Id -> Bool
+exportWithOrigOccName id = omitIfaceSigForId id || isUserExportedId id
import VarSet
import Var ( Id, IdOrTyVar )
import Id ( idType, idInfo, idName,
import VarSet
import Var ( Id, IdOrTyVar )
import Id ( idType, idInfo, idName,
- mkVanillaId, mkId, isUserExportedId,
+ mkVanillaId, mkId, exportWithOrigOccName,
getIdStrictness, setIdStrictness,
getIdDemandInfo, setIdDemandInfo,
)
getIdStrictness, setIdStrictness,
getIdDemandInfo, setIdDemandInfo,
)
-- decl. tidyTopId then does a no-op on exported binders.
init_tidy_env = (initTidyOccEnv avoids, emptyVarEnv)
avoids = [getOccName bndr | bndr <- bindersOfBinds binds_in,
-- decl. tidyTopId then does a no-op on exported binders.
init_tidy_env = (initTidyOccEnv avoids, emptyVarEnv)
avoids = [getOccName bndr | bndr <- bindersOfBinds binds_in,
+ exportWithOrigOccName bndr]
tidyBind :: Maybe Module -- (Just m) for top level, Nothing for nested
-> TidyEnv
tidyBind :: Maybe Module -- (Just m) for top level, Nothing for nested
-> TidyEnv
tidyTopId mod env@(tidy_env, var_env) env_idinfo id
= -- Top level variables
let
tidyTopId mod env@(tidy_env, var_env) env_idinfo id
= -- Top level variables
let
- (tidy_env', name') | isUserExportedId id = (tidy_env, idName id)
- | otherwise = tidyTopName mod tidy_env (idName id)
+ (tidy_env', name') | exportWithOrigOccName id = (tidy_env, idName id)
+ | otherwise = tidyTopName mod tidy_env (idName id)
ty' = tidyTopType (idType id)
idinfo' = tidyIdInfo env_idinfo (idInfo id)
id' = mkId name' ty' idinfo'
ty' = tidyTopType (idType id)
idinfo' = tidyIdInfo env_idinfo (idInfo id)
id' = mkId name' ty' idinfo'