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

Compatibility with optparse-applicative-0.18 #284

Closed
Closed
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
16 changes: 6 additions & 10 deletions src/Xrefcheck/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Options.Applicative
(Mod, OptionFields, Parser, ReadM, auto, command, eitherReader, execParser, flag, flag',
footerDoc, fullDesc, help, helpDoc, helper, hsubparser, info, infoOption, long, metavar, option,
progDesc, short, strOption, switch, value)
import Options.Applicative.Help.Pretty (Doc, displayS, fill, fillSep, indent, renderPretty, text)
import Options.Applicative.Help.Pretty (Doc, fill, fillSep, indent, pretty)
import Options.Applicative.Help.Pretty qualified as Pretty
import Text.Interpolation.Nyan

Expand Down Expand Up @@ -289,18 +289,14 @@ getCommand = do
footerDoc (pure ignoreModesMsg)

ignoreModesMsg :: Doc
ignoreModesMsg = text $ header <> body
ignoreModesMsg = header <> body
where
header = "To ignore a link in your markdown, \
\include \"<!-- xrefcheck: ignore <mode> -->\"\n\
\comment with one of these modes:\n"
body = displayS (renderPretty pageParam pageWidth doc) ""

pageWidth = 80
pageParam = 1

doc = fillSep $ map formatDesc modeDescr
body = fillSep $ map formatDesc modeDescr

modeDescr :: [(String, [String])]
modeDescr =
[ (" \"link\"", L.words "Ignore the link right after the comment.")
, (" \"paragraph\"", L.words "Ignore the whole paragraph after the comment.")
Expand All @@ -312,5 +308,5 @@ ignoreModesMsg = text $ header <> body
descrIndent = 27 - modeIndent

formatDesc (mode, descr) =
fill modeIndent (text mode) <>
indent descrIndent (fillSep $ map text descr)
fill modeIndent (pretty mode) <>
indent descrIndent (fillSep $ map pretty descr)
2 changes: 1 addition & 1 deletion src/Xrefcheck/Verify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ checkExternalResource followed config@Config{..} link
other -> throwError $ ExternalResourceSomeError $ show other
where
retryAfterInfo :: Response a -> Maybe RetryAfter
retryAfterInfo = readMaybe . decodeUtf8 <=< L.lookup hRetryAfter . responseHeaders
retryAfterInfo = readMaybe . decodeUtf8 @Text <=< L.lookup hRetryAfter . responseHeaders
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, readMaybe comes from Text.Read and takes a String parameter, so it does not compile for me unless this type parameter application is removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised that I had to add it, because it is orthogonal to the concern of this PR, namely optparse-applicative.
Let me investigate some more...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So indeed stack build fails now (which uses LTS 19 which is GHC 9.0), but cabal build -w ghc-9.2.8 succeeds and needs this change.
I am gonna remove this patch, it is something to be sorted out when migrating from GHC 9.0 to 9.2 and up.
(Note that GHC 9.2.8 is the currently recommended version of GHC.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be updated at some point. I will create an issue referencing this comments thread. Thank you!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


checkFtp :: URI -> Bool -> ExceptT VerifyError IO ()
checkFtp uri secure = do
Expand Down