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

Use prettyprinter package if optparse-applicative is >=0.18 #106

Merged
merged 1 commit into from
Nov 10, 2024
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
21 changes: 21 additions & 0 deletions app/toyconvert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ import Options.Applicative
import System.IO
import System.Exit
import System.FilePath
#if MIN_VERSION_optparse_applicative(0,18,0)
import Prettyprinter ((<+>))
import qualified Prettyprinter as PP
#else
import Text.PrettyPrint.ANSI.Leijen ((<+>))
import qualified Text.PrettyPrint.ANSI.Leijen as PP
#endif

import qualified Data.PseudoBoolean as PBFile
import qualified Numeric.Optimization.MIP as MIP
Expand Down Expand Up @@ -215,6 +220,20 @@ parserInfo = info (helper <*> versionOption <*> optionsParser)
<> long "version"
<> help "Show version"

#if MIN_VERSION_optparse_applicative(0,18,0)

supportedFormatsDoc :: PP.Doc ann
supportedFormatsDoc =
PP.vsep
[ PP.pretty "Supported formats:"
, PP.indent 2 $ PP.vsep
[ PP.pretty "input:" <+> (PP.align $ PP.fillSep $ map PP.pretty $ words ".cnf .wcnf .opb .wbo .gcnf .lp .mps .qubo")
, PP.pretty "output:" <+> (PP.align $ PP.fillSep $ map PP.pretty $ words ".cnf .wcnf .opb .wbo .lsp .lp .mps .smp .smt2 .ys .qubo")
]
]

#else

supportedFormatsDoc :: PP.Doc
supportedFormatsDoc =
PP.vsep
Expand All @@ -225,6 +244,8 @@ supportedFormatsDoc =
]
]

#endif

data Problem
= ProbOPB PBFile.Formula
| ProbWBO PBFile.SoftFormula
Expand Down
2 changes: 1 addition & 1 deletion toysolver.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ Executable toyconvert
if flag(optparse-applicative-018)
Build-Depends:
optparse-applicative >=0.18,
ansi-wl-pprint >=1.0
prettyprinter >=1
else
Build-Depends:
optparse-applicative <0.18,
Expand Down
Loading