@@ -755,21 +755,23 @@ suggestExportUnusedTopBinding srcOpt ParsedModule{pm_parsed_source = L _ HsModul
755
755
opLetter :: T. Text
756
756
opLetter = " :!#$%&*+./<=>?@\\ ^|-~"
757
757
758
+ parenthesizeIfNeeds :: Bool -> T. Text -> T. Text
759
+ parenthesizeIfNeeds needsTypeKeyword x
760
+ | T. any (c == ) opLetter = (if needsTypeKeyword then " type " else " " ) <> " (" <> x <> " )"
761
+ | otherwise = x
762
+ where
763
+ c = T. head x
764
+
758
765
matchWithDiagnostic :: Range -> Located (IdP GhcPs ) -> Bool
759
766
matchWithDiagnostic Range {_start= l,_end= r} x =
760
767
let loc = fmap _start . getLocatedRange $ x
761
768
in loc >= Just l && loc <= Just r
762
769
763
770
printExport :: ExportsAs -> T. Text -> T. Text
764
- printExport ea name = prefix <> parenthesizedName <> suffix
765
- where
766
- parenthesizedName = if T. any (firstChar == ) opLetter then " (" <> name <> " )" else name
767
- firstChar = T. head name
768
- (prefix, suffix) = case ea of
769
- ExportName -> (" " , " " )
770
- ExportPattern -> (" pattern " , " " )
771
- ExportFamily -> (" type " , " " )
772
- ExportAll -> (" type " , " (..)" )
771
+ printExport ExportName x = parenthesizeIfNeeds False x
772
+ printExport ExportPattern x = " pattern " <> parenthesizeIfNeeds False x
773
+ printExport ExportFamily x = parenthesizeIfNeeds True x
774
+ printExport ExportAll x = parenthesizeIfNeeds True x <> " (..)"
773
775
774
776
isTopLevel :: SrcSpan -> Bool
775
777
isTopLevel span = fmap (_character . _start) (srcSpanToRange span ) == Just 0
0 commit comments