From 669f241fc4b783da391695849b0a50b228d70408 Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Sat, 12 Oct 2024 16:12:49 +0900 Subject: [PATCH] Suppress warnings in `src/HIndent/ModulePreprocessing.hs` (#961) --- src/HIndent/ModulePreprocessing.hs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/HIndent/ModulePreprocessing.hs b/src/HIndent/ModulePreprocessing.hs index 5bcb16a6d..f01547036 100644 --- a/src/HIndent/ModulePreprocessing.hs +++ b/src/HIndent/ModulePreprocessing.hs @@ -11,21 +11,21 @@ module HIndent.ModulePreprocessing ( modifyASTForPrettyPrinting ) where -import Control.Applicative import Data.Function import Data.List -import Data.Maybe import GHC.Hs -import GHC.Stack import GHC.Types.SrcLoc import Generics.SYB hiding (GT, typeOf, typeRep) import HIndent.Fixity import HIndent.GhcLibParserWrapper.GHC.Hs import HIndent.ModulePreprocessing.CommentRelocation import Language.Haskell.GhclibParserEx.Fixity -import Type.Reflection #if MIN_VERSION_ghc_lib_parser(9, 10, 1) import qualified GHC.Data.Strict as Strict +#else +import Control.Applicative +import Data.Maybe +import Type.Reflection #endif -- | This function modifies the given module AST for pretty-printing. -- @@ -278,8 +278,8 @@ resetLGRHSEndPosition :: #if MIN_VERSION_ghc_lib_parser(9, 10, 1) resetLGRHSEndPosition (L locAnn (GRHS ext@EpAnn {..} stmt body)) = let lastPosition = - maximum $ realSrcSpanEnd . getAnc <$> listify collectAnchor body - newSpan = mkRealSrcSpan (realSrcSpanStart $ getAnc entry) lastPosition + maximum $ realSrcSpanEnd . anchor <$> listify collectAnchor body + newSpan = mkRealSrcSpan (realSrcSpanStart $ anchor entry) lastPosition newLocAnn = locAnn {entry = realSpanAsAnchor newSpan} newAnn = ext {entry = realSpanAsAnchor newSpan} in L newLocAnn (GRHS newAnn stmt body) @@ -298,6 +298,7 @@ resetLGRHSEndPosition (L (SrcSpanAnn locAnn@EpAnn {} sp) (GRHS ext@EpAnn {..} st where collectAnchor :: Anchor -> Bool collectAnchor _ = True +resetLGRHSEndPosition x = x #else resetLGRHSEndPosition (L _ (GRHS ext@EpAnn {..} stmt body)) = let lastPosition = @@ -309,18 +310,10 @@ resetLGRHSEndPosition (L _ (GRHS ext@EpAnn {..} stmt body)) = where collectAnchor :: Anchor -> Bool collectAnchor _ = True -#endif resetLGRHSEndPosition x = x - +#endif isEofComment :: EpaCommentTok -> Bool #if !MIN_VERSION_ghc_lib_parser(9, 10, 1) isEofComment EpaEofComment = True #endif isEofComment _ = False -#if MIN_VERSION_ghc_lib_parser(9, 10, 1) -getAnc :: HasCallStack => EpaLocation' a -> RealSrcSpan -getAnc (EpaSpan (RealSrcSpan x _)) = x -getAnc _ = undefined -#else -getAnc = anchor -#endif