packages feed

opt-env-conf 0.7.0.1 → 0.8.0.0

raw patch · 4 files changed

+14/−9 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- OptEnvConf: withShownDefault :: a -> String -> Parser a -> Parser a
+ OptEnvConf: withShownDefault :: (a -> String) -> a -> Parser a -> Parser a
- OptEnvConf.Parser: withShownDefault :: a -> String -> Parser a -> Parser a
+ OptEnvConf.Parser: withShownDefault :: (a -> String) -> a -> Parser a -> Parser a
- OptEnvConf.Setting: valueWithShown :: a -> String -> Builder a
+ OptEnvConf.Setting: valueWithShown :: (a -> String) -> a -> Builder a

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +## [0.8.0.0] - 2024-11-05++* Change `withShownDefault` and `valueWithShown` to accept a function to use in+  place of `show` rather than a pre-rendered `String`.+ ## [0.7.0.1] - 2024-10-27  ### Changed
opt-env-conf.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           opt-env-conf-version:        0.7.0.1+version:        0.8.0.0 synopsis:       Settings parsing for Haskell: command-line arguments, environment variables, and configuration values. homepage:       https://github.com/NorfairKing/opt-env-conf#readme bug-reports:    https://github.com/NorfairKing/opt-env-conf/issues
src/OptEnvConf/Parser.hs view
@@ -515,12 +515,12 @@ -- -- This does nothing if the parser already has a default value. withDefault :: (Show a) => a -> Parser a -> Parser a-withDefault defaultValue = withShownDefault defaultValue (show defaultValue)+withDefault = withShownDefault show  -- | Like 'withDefault' but lets you specfiy how to show the default value -- yourself.-withShownDefault :: a -> String -> Parser a -> Parser a-withShownDefault defaultValue shownDefault = go+withShownDefault :: (a -> String) -> a -> Parser a -> Parser a+withShownDefault showDefault defaultValue = go   where     go p =       let p' = p <|> pure defaultValue@@ -537,7 +537,7 @@             ParserCommands {} -> p'             ParserWithConfig {} -> p'             ParserSetting mLoc s -> case settingDefaultValue s of-              Nothing -> ParserSetting mLoc $ s {settingDefaultValue = Just (defaultValue, shownDefault)}+              Nothing -> ParserSetting mLoc $ s {settingDefaultValue = Just (defaultValue, showDefault defaultValue)}               Just _ -> p  -- | Try a list of parsers in order
src/OptEnvConf/Setting.hs view
@@ -349,11 +349,11 @@ -- API Note: @default@ is not a valid identifier in Haskell. -- I'd also have preferred @default@ instead. value :: (Show a) => a -> Builder a-value a = valueWithShown a (show a)+value = valueWithShown show --- | Set the default value, along with a shown version of it.-valueWithShown :: a -> String -> Builder a-valueWithShown a shown = Builder [BuildSetDefault a shown]+-- | Set the default value, along with version of it shown by a custom function.+valueWithShown :: (a -> String) -> a -> Builder a+valueWithShown show' a = Builder [BuildSetDefault a (show' a)]  -- | Provide an example value for documentation. --