packages feed

opt-env-conf 0.5.0.1 → 0.5.1.0

raw patch · 4 files changed

+9/−34 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- OptEnvConf.Lint: LintErrorUndecodableExample :: !String -> LintErrorMessage
- OptEnvConf.Reader: instance Control.Monad.Reader.Class.MonadReader GHC.Base.String OptEnvConf.Reader.Reader
- OptEnvConf.Reader: instance GHC.Base.Applicative OptEnvConf.Reader.Reader
- OptEnvConf.Reader: instance GHC.Base.Monad OptEnvConf.Reader.Reader

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.5.1.0] - 2024-08-08++### Removed++* Removed the "undecodable example" lint because it was faulty when example values aren't Strings.+ ## [0.5.0.1] - 2024-08-04  ### Changed
opt-env-conf.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           opt-env-conf-version:        0.5.0.1+version:        0.5.1.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/Lint.hs view
@@ -13,10 +13,8 @@   ) where -import Autodocodec import Control.Monad import Control.Monad.Reader-import qualified Data.Aeson.Types as JSON import Data.Either import Data.Foldable import Data.List.NonEmpty (NonEmpty (..))@@ -53,7 +51,6 @@   | LintErrorNoMetavarForEnvVar   | LintErrorNoCommands   | LintErrorUnreadableExample !String-  | LintErrorUndecodableExample !String   | LintErrorConfigWithoutLoad   | LintErrorManyInfinite @@ -203,10 +200,6 @@           [ [functionChunk "example", " was called with an example that none of the ", functionChunk "reader", "s succeed in reading."],             ["Example: ", chunk $ T.pack e]           ]-        LintErrorUndecodableExample e ->-          [ [functionChunk "example", " was called with an example that none of the ", functionChunk "conf", "s succeed in decoding."],-            ["Example: ", chunk $ T.pack e]-          ]         LintErrorConfigWithoutLoad ->           [ [ functionChunk "conf",               " or ",@@ -326,11 +319,6 @@            in when ((settingTryArgument || settingTryOption) && not (any canRead settingReaders)) $                 validationTFailure $                   LintErrorUnreadableExample e-        for_ settingExamples $ \e ->-          let canDecode (ConfigValSetting _ c) = isRight $ JSON.parseEither (parseJSONVia c) (JSON.String (T.pack e))-           in when (isJust settingConfigVals && not (any canDecode (maybe [] NE.toList settingConfigVals))) $-                validationTFailure $-                  LintErrorUndecodableExample e         hasConfig <- ask         when (isJust settingConfigVals && not hasConfig) $           validationTFailure LintErrorConfigWithoutLoad
src/OptEnvConf/Reader.hs view
@@ -31,7 +31,6 @@ where  import Autodocodec-import Control.Monad.Reader (MonadReader (..)) import Data.Aeson.Types as JSON import Data.List (intercalate) import Data.List.NonEmpty (NonEmpty (..), (<|))@@ -45,24 +44,6 @@ newtype Reader a = Reader {unReader :: String -> Either String a}   deriving (Functor) -instance Applicative Reader where-  pure = Reader . const . Right-  (<*>) (Reader ff) (Reader fa) =-    Reader $ \s ->-      ff s <*> fa s--instance Monad Reader where-  (>>=) (Reader fa) fb = Reader $ \s -> do-    a <- fa s-    unReader (fb a) s--instance MonadReader String Reader where-  ask = Reader Right-  reader f = Reader $ \s -> Right (f s)-  local fs f = Reader $ \s ->-    let s' = fs s-     in unReader f s'- runReader :: Reader a -> String -> Either String a runReader = unReader @@ -94,8 +75,8 @@  -- | Turn a 'Maybe' parsing function into a 'Reader' maybeReader :: (String -> Maybe a) -> Reader a-maybeReader func = Reader $ \s -> case func s of-  Nothing -> Left $ "Unparsable value: " <> show s+maybeReader func = eitherReader $ \s -> case func s of+  Nothing -> Left $ "Unparseable value: " <> show s   Just a -> Right a  -- | Turn an 'Either' parsing function into a 'Reader'