From b12f8982acd772f9cc9e1e013738ff535f1b9a2a Mon Sep 17 00:00:00 2001 From: Taylor Fausak Date: Fri, 29 Oct 2021 00:38:29 +0000 Subject: [PATCH] Fix up layouter basics --- .../Haskell/Brittany/Internal/LayouterBasics.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Language/Haskell/Brittany/Internal/LayouterBasics.hs b/src/Language/Haskell/Brittany/Internal/LayouterBasics.hs index 770cbdd..12b07f2 100644 --- a/src/Language/Haskell/Brittany/Internal/LayouterBasics.hs +++ b/src/Language/Haskell/Brittany/Internal/LayouterBasics.hs @@ -99,6 +99,15 @@ import Language.Haskell.Brittany.Internal.Types import Language.Haskell.Brittany.Internal.Utils import Language.Haskell.Brittany.Internal.ExactPrintUtils +#if MIN_VERSION_ghc(9,0,0) +import GHC.Types.Name.Reader ( RdrName(..) ) +import GHC ( Located, runGhc, GenLocated(L), moduleNameString ) +import qualified GHC.Types.SrcLoc as GHC +import GHC.Types.Name.Occurrence ( occNameString ) +import GHC.Types.Name ( getOccString ) +import GHC ( moduleName ) +import GHC.Parser.Annotation ( AnnKeywordId(..) ) +#else import RdrName ( RdrName(..) ) import GHC ( Located, runGhc, GenLocated(L), moduleNameString ) import qualified SrcLoc as GHC @@ -106,6 +115,7 @@ import OccName ( occNameString ) import Name ( getOccString ) import Module ( moduleName ) import ApiAnnotation ( AnnKeywordId(..) ) +#endif import Data.Data import Data.Generics.Schemes @@ -299,7 +309,13 @@ filterAnns ast = -- b) after (in source code order) the node. hasAnyCommentsBelow :: Data ast => GHC.Located ast -> ToBriDocM Bool hasAnyCommentsBelow ast@(L l _) = +#if MIN_VERSION_ghc(9,0,0) + case l of + GHC.RealSrcSpan rss _ -> List.any (\(c, _) -> ExactPrint.commentIdentifier c > rss) + GHC.UnhelpfulSpan _ -> const False +#else List.any (\(c, _) -> ExactPrint.commentIdentifier c > l) +#endif <$> astConnectedComments ast hasCommentsBetween