Skip to content

Commit

Permalink
Split Pretty instance based on GHC version
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Maruseac <mihai.maruseac@gmail.com>
  • Loading branch information
mihaimaruseac committed Nov 12, 2023
1 parent 3177309 commit 257580f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/HIndent/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2040,13 +2040,25 @@ instance Pretty FamEqn' where
DataFamInstDeclForInsideClassInst -> "data"

-- | HsArg (LHsType GhcPs) (LHsType GhcPs)
#if MIN_VERSION_ghc_lib_parser(9,8,1)
instance Pretty
(HsArg
GhcPs
(GenLocated SrcSpanAnnA (HsType GhcPs))
(GenLocated SrcSpanAnnA (HsType GhcPs))) where
pretty' (HsValArg x) = pretty x
pretty' (HsTypeArg _ x) = string "@" >> pretty x
pretty' HsArgPar {} = notUsedInParsedStage
#else
instance Pretty
(HsArg
(GenLocated SrcSpanAnnA (HsType GhcPs))
(GenLocated SrcSpanAnnA (HsType GhcPs))) where
pretty' (HsValArg x) = pretty x
pretty' (HsTypeArg _ x) = string "@" >> pretty x
pretty' HsArgPar {} = notUsedInParsedStage
#endif

#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance Pretty (HsQuote GhcPs) where
pretty' (ExpBr _ x) = brackets $ wrapWithBars $ pretty x
Expand All @@ -2058,13 +2070,15 @@ instance Pretty (HsQuote GhcPs) where
pretty' (VarBr _ True x) = string "'" >> pretty x
pretty' (VarBr _ False x) = string "''" >> pretty x
#endif

#if MIN_VERSION_ghc_lib_parser(9,6,1)
instance Pretty (WarnDecls GhcPs) where
pretty' (Warnings _ x) = lined $ fmap pretty x
#else
instance Pretty (WarnDecls GhcPs) where
pretty' (Warnings _ _ x) = lined $ fmap pretty x
#endif

instance Pretty (WarnDecl GhcPs) where
pretty' (Warning _ names deprecatedOrWarning) =
case deprecatedOrWarning of
Expand All @@ -2078,6 +2092,7 @@ instance Pretty (WarnDecl GhcPs) where
[hCommaSep $ fmap pretty names, hCommaSep $ fmap pretty reasons]
, string " #-}"
]

#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance Pretty (WithHsDocIdentifiers StringLiteral GhcPs) where
pretty' WithHsDocIdentifiers {..} = pretty hsDocString
Expand Down

0 comments on commit 257580f

Please sign in to comment.