Skip to content

Commit

Permalink
Merge pull request #106 from msakai/use-prettyprinter-package
Browse files Browse the repository at this point in the history
Use prettyprinter package if optparse-applicative is >=0.18
  • Loading branch information
msakai authored Nov 10, 2024
2 parents c3850a7 + 882789a commit 948c346
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit 948c346

Please sign in to comment.