Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary parentheses #702

Merged
merged 5 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/HIndent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ hasTrailingLine :: ByteString -> Bool
hasTrailingLine xs = not (S8.null xs) && S8.last xs == '\n'
-- | Print the module.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
prettyPrint :: Config -> (HsModule GhcPs) -> Builder
prettyPrint :: Config -> HsModule GhcPs -> Builder
#else
prettyPrint :: Config -> HsModule -> Builder
#endif
Expand Down
24 changes: 12 additions & 12 deletions src/HIndent/ModulePreprocessing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Type.Reflection
-- Pretty-printing a module without calling this function for it before may
-- raise an error or not print it correctly.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
modifyASTForPrettyPrinting :: (HsModule GhcPs) -> (HsModule GhcPs)
modifyASTForPrettyPrinting :: HsModule GhcPs -> HsModule GhcPs
#else
modifyASTForPrettyPrinting :: HsModule -> HsModule
#endif
Expand All @@ -47,7 +47,7 @@ modifyASTForPrettyPrinting m = relocateComments (beforeRelocation m) allComments
-- | This function modifies the given module AST to apply fixities of infix
-- operators defined in the 'base' package.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
fixFixities :: (HsModule GhcPs) -> (HsModule GhcPs)
fixFixities :: HsModule GhcPs -> HsModule GhcPs
#else
fixFixities :: HsModule -> HsModule
#endif
Expand All @@ -60,7 +60,7 @@ fixFixities = applyFixities baseFixities
-- relocation. This function prevents it by fixing the 'L?GRHS''s source
-- span.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
resetLGRHSEndPositionInModule :: (HsModule GhcPs) -> (HsModule GhcPs)
resetLGRHSEndPositionInModule :: HsModule GhcPs -> HsModule GhcPs
#else
resetLGRHSEndPositionInModule :: HsModule -> HsModule
#endif
Expand All @@ -71,7 +71,7 @@ resetLGRHSEndPositionInModule = everywhere (mkT resetLGRHSEndPosition)
-- before a bar, and the elements are not sorted by their locations. This
-- function fixes the orderings.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
sortExprLStmt :: (HsModule GhcPs) -> (HsModule GhcPs)
sortExprLStmt :: HsModule GhcPs -> HsModule GhcPs
#else
sortExprLStmt :: HsModule -> HsModule
#endif
Expand All @@ -83,15 +83,15 @@ sortExprLStmt m@HsModule {hsmodDecls = xs} = m {hsmodDecls = sorted}
-- | This function removes all comments from the given module not to
-- duplicate them on comment relocation.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
removeComments :: (HsModule GhcPs) -> (HsModule GhcPs)
removeComments :: HsModule GhcPs -> HsModule GhcPs
#else
removeComments :: HsModule -> HsModule
#endif
removeComments = everywhere (mkT $ const emptyComments)
-- | This function replaces all 'EpAnnNotUsed's in 'SrcSpanAnn''s with
-- 'EpAnn's to make it possible to locate comments on them.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
replaceAllNotUsedAnns :: (HsModule GhcPs) -> (HsModule GhcPs)
replaceAllNotUsedAnns :: HsModule GhcPs -> HsModule GhcPs
#else
replaceAllNotUsedAnns :: HsModule -> HsModule
#endif
Expand Down Expand Up @@ -124,7 +124,7 @@ replaceAllNotUsedAnns = everywhere app
-- | This function sets the start column of 'hsmodName' of the given
-- 'HsModule' to 1 to correctly locate comments above the module name.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
resetModuleNameColumn :: (HsModule GhcPs) -> (HsModule GhcPs)
resetModuleNameColumn :: HsModule GhcPs -> HsModule GhcPs
#else
resetModuleNameColumn :: HsModule -> HsModule
#endif
Expand All @@ -145,7 +145,7 @@ resetModuleNameColumn m = m
-- also contains the name, and we use the latter one. This function
-- prevents comments from being located in 'fun_id'.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
closeEpAnnOfFunBindFunId :: (HsModule GhcPs) -> (HsModule GhcPs)
closeEpAnnOfFunBindFunId :: HsModule GhcPs -> HsModule GhcPs
#else
closeEpAnnOfFunBindFunId :: HsModule -> HsModule
#endif
Expand All @@ -162,7 +162,7 @@ closeEpAnnOfFunBindFunId = everywhere (mkT closeEpAnn)
-- information is also stored inside the 'Match'. This function removes the
-- duplication not to locate comments on a wrong point.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
closeEpAnnOfMatchMExt :: (HsModule GhcPs) -> (HsModule GhcPs)
closeEpAnnOfMatchMExt :: HsModule GhcPs -> HsModule GhcPs
#else
closeEpAnnOfMatchMExt :: HsModule -> HsModule
#endif
Expand All @@ -183,7 +183,7 @@ closeEpAnnOfMatchMExt = everywhere closeEpAnn
-- 'HsFunTy' should not have any comments. Instead, its LHS and RHS should
-- have them.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
closeEpAnnOfHsFunTy :: (HsModule GhcPs) -> (HsModule GhcPs)
closeEpAnnOfHsFunTy :: HsModule GhcPs -> HsModule GhcPs
#else
closeEpAnnOfHsFunTy :: HsModule -> HsModule
#endif
Expand All @@ -196,7 +196,7 @@ closeEpAnnOfHsFunTy = everywhere (mkT closeEpAnn)
-- to locate comments correctly. A placeholder anchor is an anchor pointing
-- on (-1, -1).
#if MIN_VERSION_ghc_lib_parser(9,6,1)
closePlaceHolderEpAnns :: (HsModule GhcPs) -> (HsModule GhcPs)
closePlaceHolderEpAnns :: HsModule GhcPs -> HsModule GhcPs
#else
closePlaceHolderEpAnns :: HsModule -> HsModule
#endif
Expand All @@ -216,7 +216,7 @@ closePlaceHolderEpAnns = everywhere closeEpAnn
-- haddocks, but the same information is stored in 'EpaCommentTok's. Thus,
-- we need to remove the duplication.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
removeAllDocDs :: (HsModule GhcPs) -> (HsModule GhcPs)
removeAllDocDs :: HsModule GhcPs -> HsModule GhcPs
#else
removeAllDocDs :: HsModule -> HsModule
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/HIndent/Pretty/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import GHC.Types.SrcLoc
import HIndent.Pretty.Import.Sort
-- | Returns if the module has import declarations.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
importsExist :: (HsModule GhcPs) -> Bool
importsExist :: HsModule GhcPs -> Bool
#else
importsExist :: HsModule -> Bool
#endif
importsExist = not . null . hsmodImports
-- | Extracts import declarations from the given module. Adjacent import
-- declarations are grouped as a single list.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
extractImports :: (HsModule GhcPs) -> [[LImportDecl GhcPs]]
extractImports :: HsModule GhcPs -> [[LImportDecl GhcPs]]
#else
extractImports :: HsModule -> [[LImportDecl GhcPs]]
#endif
extractImports = groupImports . sortImportsByLocation . hsmodImports
-- | Extracts import declarations from the given module and sorts them by
-- their names. Adjacent import declarations are grouped as a single list.
#if MIN_VERSION_ghc_lib_parser(9,6,1)
extractImportsSorted :: (HsModule GhcPs) -> [[LImportDecl GhcPs]]
extractImportsSorted :: HsModule GhcPs -> [[LImportDecl GhcPs]]
#else
extractImportsSorted :: HsModule -> [[LImportDecl GhcPs]]
#endif
Expand Down