diff options
Diffstat (limited to 'compiler/GHC/Types/Hint.hs')
-rw-r--r-- | compiler/GHC/Types/Hint.hs | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/compiler/GHC/Types/Hint.hs b/compiler/GHC/Types/Hint.hs index 6304b1d7fd..a3b40dbf2f 100644 --- a/compiler/GHC/Types/Hint.hs +++ b/compiler/GHC/Types/Hint.hs @@ -9,6 +9,8 @@ module GHC.Types.Hint ( , HowInScope(..) , SimilarName(..) , StarIsType(..) + , UntickedPromotedThing(..) + , pprUntickedConstructor, isBareSymbol , suggestExtension , suggestExtensionWithInfo , suggestExtensions @@ -29,7 +31,8 @@ import Data.Typeable import GHC.Unit.Module (ModuleName, Module) import GHC.Hs.Extension (GhcTc) import GHC.Core.Coercion -import GHC.Types.Name (Name, NameSpace, OccName (occNameFS)) +import GHC.Types.Fixity (LexicalFixity(..)) +import GHC.Types.Name (Name, NameSpace, OccName (occNameFS), isSymOcc, nameOccName) import GHC.Types.Name.Reader (RdrName (Unqual), ImpDeclSpec) import GHC.Types.SrcLoc (SrcSpan) import GHC.Types.Basic (Activation, RuleName) @@ -342,12 +345,12 @@ data GhcHint -} | SuggestDumpSlices - {-| Suggests adding a tick to refer to a data constructor - at the type level. + {-| Suggests adding a tick to refer to something which has been + promoted to the type level, e.g. a data constructor. - Test case: T9778. + Test cases: T9778, T19984. -} - | SuggestAddTick Name + | SuggestAddTick UntickedPromotedThing {-| Something is split off from its corresponding declaration. For example, a datatype is given a role declaration @@ -422,6 +425,33 @@ data SimilarName = SimilarName Name | SimilarRdrName RdrName HowInScope +-- | Something is promoted to the type-level without a promotion tick. +data UntickedPromotedThing + = UntickedConstructor LexicalFixity Name + | UntickedExplicitList + +pprUntickedConstructor :: LexicalFixity -> Name -> SDoc +pprUntickedConstructor fixity nm = + case fixity of + Prefix -> pprPrefixVar is_op ppr_nm -- e.g. (:) and '(:) + Infix -> pprInfixVar is_op ppr_nm -- e.g. `Con` and '`Con` + where + ppr_nm = ppr nm + is_op = isSymOcc (nameOccName nm) + +-- | Whether a constructor name is printed out as a bare symbol, e.g. @:@. +-- +-- True for symbolic names in infix position. +-- +-- Used for pretty-printing. +isBareSymbol :: LexicalFixity -> Name -> Bool +isBareSymbol fixity nm + | isSymOcc (nameOccName nm) + , Infix <- fixity + = True + | otherwise + = False + -------------------------------------------------------------------------------- -- | Whether '*' is a synonym for 'Data.Kind.Type'. |