optparse-generic 1.4.5 → 1.4.6
raw patch · 3 files changed
+16/−5 lines, 3 filesdep +transformers-compatdep ~base
Dependencies added: transformers-compat
Dependency ranges changed: base
Files
- CHANGELOG.md +4/−0
- optparse-generic.cabal +3/−2
- src/Options/Generic.hs +9/−3
CHANGELOG.md view
@@ -1,3 +1,7 @@+1.4.6++* Use `readField` in default implementation of `parseField`+ 1.4.5 * [Add ability to set the short name in the type](https://github.com/Gabriel439/Haskell-Optparse-Generic-Library/pull/84)
optparse-generic.cabal view
@@ -1,5 +1,5 @@ Name: optparse-generic-Version: 1.4.5+Version: 1.4.6 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3@@ -24,10 +24,11 @@ Library Hs-Source-Dirs: src Build-Depends:- base >= 4.6 && < 5 ,+ base >= 4.7 && < 5 , system-filepath >= 0.3.1 && < 0.5 , text < 1.3 , transformers >= 0.2.0.0 && < 0.7 ,+ transformers-compat >= 0.3 && < 0.8 , Only < 0.2 , optparse-applicative >= 0.16.0.0 && < 0.17, time >= 1.5 && < 1.13,
src/Options/Generic.hs view
@@ -329,6 +329,8 @@ import Control.Applicative import Control.Monad.IO.Class (MonadIO(..))+import Control.Monad.Trans.Except (runExcept)+import Control.Monad.Trans.Reader (runReaderT) import Data.Char (isUpper, toLower, toUpper) import Data.Int (Int8, Int16, Int32, Int64) import Data.Maybe (listToMaybe)@@ -397,8 +399,7 @@ -- ^ Default value -> Parser a default parseField- :: Read a- => Maybe Text+ :: Maybe Text -- ^ Help message -> Maybe Text -- ^ Field label@@ -419,7 +420,7 @@ <> Options.long (Data.Text.unpack name) <> foldMap (Options.help . Data.Text.unpack) h <> foldMap Options.short c- <> foldMap Options.value (d >>= Text.Read.readMaybe)+ <> foldMap Options.value (d >>= runReadM readField) <> foldMap (Options.showDefaultWith . const) d Options.option readField fs @@ -446,6 +447,11 @@ metavar :: proxy a -> String default metavar :: Typeable a => proxy a -> String metavar _ = map toUpper (show (Data.Typeable.typeOf (undefined :: a)))++-- | a readMaybe using provided ReadM+runReadM :: ReadM a -> String -> Maybe a+runReadM r s = either (const Nothing) Just $+ runExcept (runReaderT (Options.unReadM r) s) instance ParseField Bool instance ParseField Double