diff --git a/Criterion/Main/Options.hs b/Criterion/Main/Options.hs index 42743a0..7c9ea61 100644 --- a/Criterion/Main/Options.hs +++ b/Criterion/Main/Options.hs @@ -25,7 +25,6 @@ module Criterion.Main.Options import Control.Monad (when) import Criterion.Analysis (validateAccessors) -import Criterion.Main.Options.Internal (tabulate, text) import Criterion.Types (Config(..), Verbosity(..), measureAccessors, measureKeys) import Data.Char (isSpace, toLower) @@ -35,12 +34,14 @@ import Data.List (isPrefixOf) import Data.Version (showVersion) import GHC.Generics (Generic) import Options.Applicative -import Options.Applicative.Help (Chunk(..)) -import Options.Applicative.Help.Pretty ((.$.), Doc) +import Options.Applicative.Help (Chunk(..), tabulate) +import Options.Applicative.Help.Pretty ((.$.)) import Options.Applicative.Types import Paths_criterion (version) import Prelude () import Prelude.Compat +import Prettyprinter (Doc, pretty) +import Prettyprinter.Render.Terminal (AnsiStyle) import Statistics.Types (mkCL,cl95) import qualified Data.Map as M @@ -239,8 +240,10 @@ versionInfo :: String versionInfo = "built with criterion " <> showVersion version -- We sort not by name, but by likely frequency of use. -regressionHelp :: Chunk Doc +regressionHelp :: Chunk (Doc AnsiStyle) regressionHelp = - fmap (text "Regression metrics (for use with --regress):" .$.) $ - tabulate [(text n,text d) | (n,(_,d)) <- map f measureKeys] + fmap (pretty "Regression metrics (for use with --regress):" .$.) $ + tabulate + (prefTabulateFill defaultPrefs) + [(pretty n, pretty d) | (n,(_,d)) <- map f measureKeys] where f k = (k, measureAccessors M.! k) diff --git a/Criterion/Main/Options/Internal.hs b/Criterion/Main/Options/Internal.hs deleted file mode 100644 index 9dc6711..0000000 --- a/Criterion/Main/Options/Internal.hs +++ /dev/null @@ -1,52 +0,0 @@ -{-# LANGUAGE CPP #-} - --- | --- Module : Criterion.Main.Options.Internal --- Copyright : (c) 2022 Ryan Scott --- --- License : BSD-style --- Maintainer : bos@serpentine.com --- Stability : experimental --- Portability : GHC --- --- Provides a shim on top of @optparse-applicative@ to define two functions: --- --- * Define a 'tabulate' function that is backwards-compatible with --- pre-@0.17.*@ versions of @optparse-applicative@. --- * Define a 'text' function that is forward-compatible with --- @optparse-applicative-0.18.*@ or later. --- --- These are deliberately kept separate from the rest of --- "Criterion.Main.Options" because these functions require CPP to define, and --- there is a Haddock comment in "Criterion.Main.Options" that will cause the --- CPP preprocessor to trigger an \"unterminated comment\" error. Ugh. --- --- TODO: When we support @optparse-applicative-0.18@ as the minimum, remove --- this module, and simply inline the definitions of 'tabulate' and 'text' in --- "Criterion.Main.Options". -module Criterion.Main.Options.Internal (tabulate, text) where - -import qualified Options.Applicative.Help as Options -import Options.Applicative.Help (Chunk, Doc) - -#if MIN_VERSION_optparse_applicative(0,17,0) -import Options.Applicative (ParserPrefs(..), defaultPrefs) -#endif - --- | A shim on top of 'Options.tabulate' from @optparse-applicative@ that is --- backwards-compatible with pre-@0.17.*@ versions of @optparse-applicative@. -tabulate :: [(Doc, Doc)] -> Chunk Doc -#if MIN_VERSION_optparse_applicative(0,17,0) -tabulate = Options.tabulate (prefTabulateFill defaultPrefs) -#else -tabulate = Options.tabulate -#endif - --- | A shim on top of 'Options.pretty' from @optparse-applicative@ that is --- forward-compatible with @optparse-applicative-0.18.*@ or later. -text :: String -> Doc -#if MIN_VERSION_optparse_applicative(0,18,0) -text = Options.pretty -#else -text = Options.text -#endif diff --git a/changelog.md b/changelog.md index da7be80..9d75cc5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +1.6.2.0 + +* Require `optparse-applicative-0.18.*` as the minimum and add an explicit + dependency on `prettyprinter` and `prettyprinter-ansi-terminal`. + 1.6.1.0 * Support building with `optparse-applicative-0.18.*`. diff --git a/criterion.cabal b/criterion.cabal index 725677d..5c9cf07 100644 --- a/criterion.cabal +++ b/criterion.cabal @@ -1,5 +1,5 @@ name: criterion -version: 1.6.1.0 +version: 1.6.2.0 synopsis: Robust, reliable performance measurement and analysis license: BSD3 license-file: LICENSE @@ -77,7 +77,6 @@ library Criterion.Types other-modules: - Criterion.Main.Options.Internal Criterion.Monad.Internal other-modules: @@ -105,9 +104,10 @@ library js-chart >= 2.9.4 && < 3, mtl >= 2, mwc-random >= 0.8.0.3, - -- TODO: Depend on optparse-applicative-0.18 as the minimum (see #258) - optparse-applicative >= 0.13 && < 0.19, + optparse-applicative >= 0.18 && < 0.19, parsec >= 3.1.0, + prettyprinter >= 1.7 && < 1.8, + prettyprinter-ansi-terminal >= 1.1 && < 1.2, statistics >= 0.14 && < 0.17, text >= 0.11, time,