{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module GHC.Types.Hint.Ppr (
perhapsAsPat
) where
import GHC.Prelude
import GHC.Parser.Errors.Basic
import GHC.Types.Hint
import GHC.Hs.Expr ()
import GHC.Types.Id
import GHC.Types.Name (NameSpace, pprDefinedAt, occNameSpace, pprNameSpace, isValNameSpace)
import GHC.Types.Name.Reader (RdrName,ImpDeclSpec (..), rdrNameOcc, rdrNameSpace)
import GHC.Types.SrcLoc (SrcSpan(..), srcSpanStartLine)
import GHC.Unit.Module.Imported (ImportedModsVal(..))
import GHC.Unit.Types
import GHC.Utils.Outputable
import Data.List (intersperse)
import qualified Data.List.NonEmpty as NE
instance Outputable GhcHint where
ppr :: GhcHint -> SDoc
ppr = \case
UnknownHint a
m
-> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
m
SuggestExtension LanguageExtensionHint
extHint
-> case LanguageExtensionHint
extHint of
SuggestSingleExtension SDoc
extraUserInfo Extension
ext ->
(String -> SDoc
text String
"Perhaps you intended to use" SDoc -> SDoc -> SDoc
<+> Extension -> SDoc
forall a. Outputable a => a -> SDoc
ppr Extension
ext) SDoc -> SDoc -> SDoc
$$ SDoc
extraUserInfo
SuggestAnyExtension SDoc
extraUserInfo [Extension]
exts ->
let header :: SDoc
header = String -> SDoc
text String
"Enable any of the following extensions:"
in SDoc
header SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
hcat (SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
intersperse (String -> SDoc
text String
", ") ((Extension -> SDoc) -> [Extension] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Extension -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Extension]
exts)) SDoc -> SDoc -> SDoc
$$ SDoc
extraUserInfo
SuggestExtensions SDoc
extraUserInfo [Extension]
exts ->
let header :: SDoc
header = String -> SDoc
text String
"Enable all of the following extensions:"
in SDoc
header SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
hcat (SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
intersperse (String -> SDoc
text String
", ") ((Extension -> SDoc) -> [Extension] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Extension -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Extension]
exts)) SDoc -> SDoc -> SDoc
$$ SDoc
extraUserInfo
SuggestExtensionInOrderTo SDoc
extraUserInfo Extension
ext ->
(String -> SDoc
text String
"Use" SDoc -> SDoc -> SDoc
<+> Extension -> SDoc
forall a. Outputable a => a -> SDoc
ppr Extension
ext) SDoc -> SDoc -> SDoc
$$ SDoc
extraUserInfo
GhcHint
SuggestMissingDo
-> String -> SDoc
text String
"Possibly caused by a missing 'do'?"
GhcHint
SuggestLetInDo
-> String -> SDoc
text String
"Perhaps you need a 'let' in a 'do' block?"
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"e.g. 'let x = 5' instead of 'x = 5'"
SuggestAddSignatureCabalFile ModuleName
pi_mod_name
-> String -> SDoc
text String
"Try adding" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
pi_mod_name)
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"to the"
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
"signatures")
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"field in your Cabal file."
SuggestSignatureInstantiations ModuleName
pi_mod_name [InstantiationSuggestion]
suggestions
-> let suggested_instantiated_with :: SDoc
suggested_instantiated_with =
[SDoc] -> SDoc
hcat (SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ([SDoc] -> [SDoc]) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$
[ ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
k SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"=" SDoc -> SDoc -> SDoc
<> Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
v
| InstantiationSuggestion ModuleName
k Module
v <- [InstantiationSuggestion]
suggestions
])
in String -> SDoc
text String
"Try passing -instantiated-with=\"" SDoc -> SDoc -> SDoc
<>
SDoc
suggested_instantiated_with SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"\"" SDoc -> SDoc -> SDoc
$$
String -> SDoc
text String
"replacing <" SDoc -> SDoc -> SDoc
<> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
pi_mod_name SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"> as necessary."
GhcHint
SuggestUseSpaces
-> String -> SDoc
text String
"Please use spaces instead."
SuggestUseWhitespaceAfter OperatorWhitespaceSymbol
sym
-> String -> SDoc
text String
"Add whitespace after the"
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (OperatorWhitespaceSymbol -> SDoc
pprOperatorWhitespaceSymbol OperatorWhitespaceSymbol
sym) SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'.'
SuggestUseWhitespaceAround String
sym OperatorWhitespaceOccurrence
_occurrence
-> String -> SDoc
text String
"Add whitespace around" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
sym) SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'.'
GhcHint
SuggestParentheses
-> String -> SDoc
text String
"Use parentheses."
GhcHint
SuggestIncreaseMaxPmCheckModels
-> String -> SDoc
text String
"Increase the limit or resolve the warnings to suppress this message."
SuggestAddTypeSignatures AvailableBindings
bindings
-> case AvailableBindings
bindings of
AvailableBindings
UnnamedBinding -> String -> SDoc
text String
"Add a type signature."
NamedBindings (Name
x NE.:| [Name]
xs) ->
let nameList :: SDoc
nameList = case [Name]
xs of
[] -> SDoc -> SDoc
quotes (SDoc -> SDoc) -> (Name -> SDoc) -> Name -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Name -> SDoc) -> Name -> SDoc
forall a b. (a -> b) -> a -> b
$ Name
x
[Name]
_ -> (Name -> SDoc) -> [Name] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (SDoc -> SDoc
quotes (SDoc -> SDoc) -> (Name -> SDoc) -> Name -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr) [Name]
xs SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"and" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
x)
in [SDoc] -> SDoc
hsep [ String -> SDoc
text String
"Consider giving"
, SDoc
nameList
, String -> SDoc
text String
"a type signature"]
SuggestBindToWildcard LHsExpr GhcTc
rhs
-> SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"Suppress this warning by saying") Int
2 (SDoc -> SDoc
quotes (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
text String
"_ <-" SDoc -> SDoc -> SDoc
<+> GenLocated SrcSpanAnnA (HsExpr GhcTc) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsExpr GhcTc
GenLocated SrcSpanAnnA (HsExpr GhcTc)
rhs)
SuggestAddInlineOrNoInlinePragma Var
lhs_id Activation
rule_act
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"Add an INLINE[n] or NOINLINE[n] pragma for" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Var -> SDoc
forall a. Outputable a => a -> SDoc
ppr Var
lhs_id)
, SDoc -> SDoc
whenPprDebug (Activation -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Var -> Activation
idInlineActivation Var
lhs_id) SDoc -> SDoc -> SDoc
$$ Activation -> SDoc
forall a. Outputable a => a -> SDoc
ppr Activation
rule_act)
]
SuggestAddPhaseToCompetingRule RuleName
bad_rule
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"Add phase [n] or [~n] to the competing rule"
, SDoc -> SDoc
whenPprDebug (RuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RuleName
bad_rule) ]
GhcHint
SuggestIncreaseSimplifierIterations
-> String -> SDoc
text String
"Set limit with -fconstraint-solver-iterations=n; n=0 for no limit"
SuggestUseTypeFromDataKind Maybe RdrName
mb_rdr_name
-> String -> SDoc
text String
"Use" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
"Type")
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"from" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
"Data.Kind") SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"instead."
SDoc -> SDoc -> SDoc
$$
SDoc -> (RdrName -> SDoc) -> Maybe RdrName -> SDoc
forall b a. b -> (a -> b) -> Maybe a -> b
maybe SDoc
empty
(\RdrName
rdr_name ->
String -> SDoc
text String
"NB: with NoStarIsType, " SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
rdr_name)
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"is treated as a regular type operator.")
Maybe RdrName
mb_rdr_name
GhcHint
SuggestQualifiedAfterModuleName
-> String -> SDoc
text String
"Place" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
"qualified")
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"after the module name."
GhcHint
SuggestThQuotationSyntax
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"Perhaps you intended to use quotation syntax of TemplateHaskell,"
, String -> SDoc
text String
"but the type variable or constructor is missing"
]
SuggestRoles [Role]
nearby
-> case [Role]
nearby of
[] -> SDoc
empty
[Role
r] -> String -> SDoc
text String
"Perhaps you meant" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Role -> SDoc
forall a. Outputable a => a -> SDoc
ppr Role
r)
[Role]
_ -> SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"Perhaps you meant one of these:")
Int
2 ((Role -> SDoc) -> [Role] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (SDoc -> SDoc
quotes (SDoc -> SDoc) -> (Role -> SDoc) -> Role -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Role -> SDoc
forall a. Outputable a => a -> SDoc
ppr) [Role]
nearby)
GhcHint
SuggestQualifyStarOperator
-> String -> SDoc
text String
"To use (or export) this operator in"
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"modules with StarIsType,"
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
" including the definition module, you must qualify it."
GhcHint
SuggestTypeSignatureForm
-> String -> SDoc
text String
"A type signature should be of form <variables> :: <type>"
SuggestAddToHSigExportList Name
_name Maybe Module
mb_mod
-> let header :: SDoc
header = String -> SDoc
text String
"Try adding it to the export list of"
in case Maybe Module
mb_mod of
Maybe Module
Nothing -> SDoc
header SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"the hsig file."
Just Module
mod -> SDoc
header SDoc -> SDoc -> SDoc
<+> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Module -> ModuleName
forall unit. GenModule unit -> ModuleName
moduleName Module
mod) SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"'s hsig file."
GhcHint
SuggestFixOrphanInstance
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"Move the instance declaration to the module of the class or of the type, or"
, String -> SDoc
text String
"wrap the type with a newtype and declare the instance on the new type."
]
GhcHint
SuggestAddStandaloneDerivation
-> String -> SDoc
text String
"Use a standalone deriving declaration instead"
GhcHint
SuggestFillInWildcardConstraint
-> String -> SDoc
text String
"Fill in the wildcard constraint yourself"
GhcHint
SuggestRenameForall
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"Consider using another name, such as"
, SDoc -> SDoc
quotes (String -> SDoc
text String
"forAll") SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<+>
SDoc -> SDoc
quotes (String -> SDoc
text String
"for_all") SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"or" SDoc -> SDoc -> SDoc
<+>
SDoc -> SDoc
quotes (String -> SDoc
text String
"forall_") SDoc -> SDoc -> SDoc
<> SDoc
dot ]
SuggestAppropriateTHTick NameSpace
ns
-> String -> SDoc
text String
"Perhaps use a" SDoc -> SDoc -> SDoc
<+> SDoc
how_many SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"tick"
where
how_many :: SDoc
how_many
| NameSpace -> Bool
isValNameSpace NameSpace
ns = String -> SDoc
text String
"single"
| Bool
otherwise = String -> SDoc
text String
"double"
GhcHint
SuggestDumpSlices
-> [SDoc] -> SDoc
vcat [ String -> SDoc
text String
"If you bound a unique Template Haskell name (NameU)"
, String -> SDoc
text String
"perhaps via newName,"
, String -> SDoc
text String
"then -ddump-splices might be useful." ]
SuggestAddTick (UntickedConstructor LexicalFixity
fixity Name
name)
-> [SDoc] -> SDoc
hsep [ String -> SDoc
text String
"Use"
, Char -> SDoc
char Char
'\'' SDoc -> SDoc -> SDoc
<> SDoc
con
, String -> SDoc
text String
"instead of"
, SDoc
con SDoc -> SDoc -> SDoc
<> SDoc
mb_dot ]
where
con :: SDoc
con = LexicalFixity -> Name -> SDoc
pprUntickedConstructor LexicalFixity
fixity Name
name
mb_dot :: SDoc
mb_dot
| LexicalFixity -> Name -> Bool
isBareSymbol LexicalFixity
fixity Name
name
= SDoc
empty
| Bool
otherwise
= SDoc
dot
SuggestAddTick UntickedPromotedThing
UntickedExplicitList
-> String -> SDoc
text String
"Add a promotion tick, e.g." SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"'[x,y,z]" SDoc -> SDoc -> SDoc
<> SDoc
dot
SuggestMoveToDeclarationSite SDoc
what RdrName
rdr_name
-> String -> SDoc
text String
"Move the" SDoc -> SDoc -> SDoc
<+> SDoc
what SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"to the declaration site of"
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
rdr_name) SDoc -> SDoc -> SDoc
<> SDoc
dot
SuggestSimilarNames RdrName
tried_rdr_name NonEmpty SimilarName
similar_names
-> case NonEmpty SimilarName
similar_names of
SimilarName
n NE.:| [] -> String -> SDoc
text String
"Perhaps use" SDoc -> SDoc -> SDoc
<+> SimilarName -> SDoc
pp_item SimilarName
n
NonEmpty SimilarName
_ -> [SDoc] -> SDoc
sep [ String -> SDoc
text String
"Perhaps use one of these:"
, Int -> SDoc -> SDoc
nest Int
2 ((SimilarName -> SDoc) -> [SimilarName] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas SimilarName -> SDoc
pp_item ([SimilarName] -> SDoc) -> [SimilarName] -> SDoc
forall a b. (a -> b) -> a -> b
$ NonEmpty SimilarName -> [SimilarName]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty SimilarName
similar_names) ]
where
tried_ns :: NameSpace
tried_ns = OccName -> NameSpace
occNameSpace (OccName -> NameSpace) -> OccName -> NameSpace
forall a b. (a -> b) -> a -> b
$ RdrName -> OccName
rdrNameOcc RdrName
tried_rdr_name
pp_item :: SimilarName -> SDoc
pp_item = NameSpace -> SimilarName -> SDoc
pprSimilarName NameSpace
tried_ns
RemindFieldSelectorSuppressed RdrName
rdr_name [Name]
parents
-> String -> SDoc
text String
"Notice that" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
rdr_name)
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"is a field selector" SDoc -> SDoc -> SDoc
<+> SDoc
whose
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"that has been suppressed by NoFieldSelectors."
where
whose :: SDoc
whose | [Name] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Name]
parents = SDoc
empty
| Bool
otherwise = String -> SDoc
text String
"belonging to the type" SDoc -> SDoc -> SDoc
<> [Name] -> SDoc
forall a. [a] -> SDoc
plural [Name]
parents
SDoc -> SDoc -> SDoc
<+> [Name] -> SDoc
forall a. Outputable a => [a] -> SDoc
pprQuotedList [Name]
parents
ImportSuggestion ImportSuggestion
import_suggestion
-> ImportSuggestion -> SDoc
pprImportSuggestion ImportSuggestion
import_suggestion
GhcHint
SuggestImportingDataCon
-> String -> SDoc
text String
"Import the data constructor to bring it into scope"
GhcHint
SuggestPlacePragmaInHeader
-> String -> SDoc
text String
"Perhaps you meant to place it in the module header?"
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"The module header is the section at the top of the file, before the" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (String -> SDoc
text String
"module") SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"keyword"
perhapsAsPat :: SDoc
perhapsAsPat :: SDoc
perhapsAsPat = String -> SDoc
text String
"Perhaps you meant an as-pattern, which must not be surrounded by whitespace"
pprImportSuggestion :: ImportSuggestion -> SDoc
pprImportSuggestion :: ImportSuggestion -> SDoc
pprImportSuggestion (CouldImportFrom NonEmpty (Module, ImportedModsVal)
mods OccName
occ_name)
| (Module
mod, ImportedModsVal
imv) NE.:| [] <- NonEmpty (Module, ImportedModsVal)
mods
= [SDoc] -> SDoc
fsep
[ String -> SDoc
text String
"Perhaps you want to add"
, SDoc -> SDoc
quotes (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ_name)
, String -> SDoc
text String
"to the import list"
, String -> SDoc
text String
"in the import of"
, SDoc -> SDoc
quotes (Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
mod)
, SDoc -> SDoc
parens (SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ImportedModsVal -> SrcSpan
imv_span ImportedModsVal
imv)) SDoc -> SDoc -> SDoc
<> SDoc
dot
]
| Bool
otherwise
= [SDoc] -> SDoc
fsep
[ String -> SDoc
text String
"Perhaps you want to add"
, SDoc -> SDoc
quotes (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ_name)
, String -> SDoc
text String
"to one of these import lists:"
]
SDoc -> SDoc -> SDoc
$$
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
vcat
[ SDoc -> SDoc
quotes (Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
mod) SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ImportedModsVal -> SrcSpan
imv_span ImportedModsVal
imv))
| (Module
mod,ImportedModsVal
imv) <- NonEmpty (Module, ImportedModsVal) -> [(Module, ImportedModsVal)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (Module, ImportedModsVal)
mods
])
pprImportSuggestion (CouldUnhideFrom NonEmpty (Module, ImportedModsVal)
mods OccName
occ_name)
| (Module
mod, ImportedModsVal
imv) NE.:| [] <- NonEmpty (Module, ImportedModsVal)
mods
= [SDoc] -> SDoc
fsep
[ String -> SDoc
text String
"Perhaps you want to remove"
, SDoc -> SDoc
quotes (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ_name)
, String -> SDoc
text String
"from the explicit hiding list"
, String -> SDoc
text String
"in the import of"
, SDoc -> SDoc
quotes (Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
mod)
, SDoc -> SDoc
parens (SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ImportedModsVal -> SrcSpan
imv_span ImportedModsVal
imv)) SDoc -> SDoc -> SDoc
<> SDoc
dot
]
| Bool
otherwise
= [SDoc] -> SDoc
fsep
[ String -> SDoc
text String
"Perhaps you want to remove"
, SDoc -> SDoc
quotes (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ_name)
, String -> SDoc
text String
"from the hiding clauses"
, String -> SDoc
text String
"in one of these imports:"
]
SDoc -> SDoc -> SDoc
$$
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
vcat
[ SDoc -> SDoc
quotes (Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
mod) SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ImportedModsVal -> SrcSpan
imv_span ImportedModsVal
imv))
| (Module
mod,ImportedModsVal
imv) <- NonEmpty (Module, ImportedModsVal) -> [(Module, ImportedModsVal)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (Module, ImportedModsVal)
mods
])
pprSimilarName :: NameSpace -> SimilarName -> SDoc
pprSimilarName :: NameSpace -> SimilarName -> SDoc
pprSimilarName NameSpace
_ (SimilarName Name
name)
= SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name) SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (Name -> SDoc
pprDefinedAt Name
name)
pprSimilarName NameSpace
tried_ns (SimilarRdrName RdrName
rdr_name HowInScope
how_in_scope)
= case HowInScope
how_in_scope of
LocallyBoundAt SrcSpan
loc ->
RdrName -> SDoc
pp_ns RdrName
rdr_name SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
rdr_name) SDoc -> SDoc -> SDoc
<+> SDoc
loc'
where
loc' :: SDoc
loc' = case SrcSpan
loc of
UnhelpfulSpan UnhelpfulSpanReason
l -> SDoc -> SDoc
parens (UnhelpfulSpanReason -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnhelpfulSpanReason
l)
RealSrcSpan RealSrcSpan
l Maybe BufSpan
_ -> SDoc -> SDoc
parens (String -> SDoc
text String
"line" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int (RealSrcSpan -> Int
srcSpanStartLine RealSrcSpan
l))
ImportedBy ImpDeclSpec
is ->
RdrName -> SDoc
pp_ns RdrName
rdr_name SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
rdr_name) SDoc -> SDoc -> SDoc
<+>
SDoc -> SDoc
parens (String -> SDoc
text String
"imported from" SDoc -> SDoc -> SDoc
<+> ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ImpDeclSpec -> ModuleName
is_mod ImpDeclSpec
is))
where
pp_ns :: RdrName -> SDoc
pp_ns :: RdrName -> SDoc
pp_ns RdrName
rdr | NameSpace
ns NameSpace -> NameSpace -> Bool
forall a. Eq a => a -> a -> Bool
/= NameSpace
tried_ns = NameSpace -> SDoc
pprNameSpace NameSpace
ns
| Bool
otherwise = SDoc
empty
where ns :: NameSpace
ns = RdrName -> NameSpace
rdrNameSpace RdrName
rdr