envparse 0.3.1 → 0.3.2
raw patch · 3 files changed
+17/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.markdown +5/−0
- envparse.cabal +2/−2
- src/Env/Parse.hs +10/−8
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.3.2+=====++ * Added `showDef`.+ 0.3.1 =====
envparse.cabal view
@@ -1,5 +1,5 @@ name: envparse-version: 0.3.1+version: 0.3.2 synopsis: Parse environment variables description: Here's a simple example of a program that uses @envparse@'s parser:@@ -68,7 +68,7 @@ source-repository this type: git location: https://github.com/supki/envparse- tag: 0.3.1+ tag: 0.3.2 library default-language:
src/Env/Parse.hs view
@@ -18,6 +18,7 @@ , auto , def , helpDef+ , showDef , flag , switch , Flag@@ -26,6 +27,7 @@ ) where import Control.Applicative+import Control.Arrow (left) import Control.Monad ((<=<)) import Data.Map (Map) import qualified Data.Map as Map@@ -48,11 +50,7 @@ readVar :: VarF e a -> Map String String -> Either [(String, e)] a readVar VarF {varfName, varfReader} =- mapLeft (pure . (\err -> (varfName, err))) . varfReader varfName--mapLeft :: (a -> b) -> Either a t -> Either b t-mapLeft f =- either (Left . f) Right+ left (pure . (\err -> (varfName, err))) . varfReader varfName -- | An environment parser@@ -139,8 +137,7 @@ -- | The reader that uses the 'Read' instance of the type auto :: (Error.AsUnread e, Read a) => Reader e a-auto = \s -> case reads s of [(v, "")] -> Right v; _ -> Left (Error.unread (show s))-{-# ANN auto "HLint: ignore Redundant lambda" #-}+auto s = case reads s of [(v, "")] -> Right v; _ -> Left (Error.unread (show s)) -- | This represents a modification of the properties of a particular 'Parser'.@@ -179,9 +176,14 @@ defaultFlag :: Flag a defaultFlag = Flag { flagHelp = Nothing } --- | Show the default value of the variable in the help text+-- | Show the default value of the variable in help. helpDef :: (a -> String) -> Mod Var a helpDef d = Mod (\v -> v { varHelpDef = Just d })++-- | Use the 'Show' instance to show the default value of the variable in help.+showDef :: Show a => Mod Var a+showDef =+ helpDef show -- | A class of things that can have a help message attached to them