packages feed

config-value-getopt 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+23/−18 lines, 3 filesdep ~basedep ~config-valuePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, config-value

API changes (from Hackage documentation)

- Config.GetOpt: configValueGetOpt :: [OptDescr a] -> Value -> ([a], [String])
+ Config.GetOpt: configValueGetOpt :: [OptDescr a] -> Value p -> ([a], [String])

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+0.1.1.0+-------+* Support `config-value-0.6`+ 0.1.0.0 ------- 
config-value-getopt.cabal view
@@ -1,5 +1,5 @@ name:                config-value-getopt-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Interface between config-value and System.GetOpt description:         This package allows to set command line configuration                      options from a file using the config-value syntax.@@ -13,6 +13,7 @@ cabal-version:       >=1.10 homepage:            https://github.com/GaloisInc/config-value-getopt bug-reports:         https://github.com/GaloisInc/config-value-getopt/issues+tested-with:         GHC==7.10.3  extra-source-files:   README.md@@ -24,8 +25,8 @@  library   exposed-modules:     Config.GetOpt-  build-depends:       base >=4.8 && <4.10,+  build-depends:       base >=4.8 && <4.11,                        text >=1.2.1.3 && <1.3,-                       config-value >=0.4 && <0.5+                       config-value >=0.6 && <0.7   hs-source-dirs:      src   default-language:    Haskell2010
src/Config/GetOpt.hs view
@@ -21,14 +21,14 @@ -- To omit an option entirely, set it to `no` or remove it from the file. -- -- Options can be provided as decimal literals or string literals.-configValueGetOpt :: [OptDescr a] -> Value -> ([a], [String])-configValueGetOpt descrs (Sections sections) =+configValueGetOpt :: [OptDescr a] -> Value p -> ([a], [String])+configValueGetOpt descrs (Sections _ sections) =   swap (partitionEithers (mapMaybe (sectionToOpts descrs) sections)) configValueGetOpt _ _ = ([],["invalid configuration value"]) -sectionToOpts :: [OptDescr a] -> Section -> Maybe (Either String a)-sectionToOpts descrs (Section k (Atom "no")) = Nothing-sectionToOpts descrs (Section k v) = Just $+sectionToOpts :: [OptDescr a] -> Section p -> Maybe (Either String a)+sectionToOpts _ (Section _ _ (Atom _ "no")) = Nothing+sectionToOpts descrs (Section _ k v) = Just $   let k' = Text.unpack k in   case lookupOption k' descrs of     Nothing -> Left (k' ++ ": unknown option")@@ -38,27 +38,27 @@         OptArg f _ -> optArg k' v f         ReqArg f _ -> reqArg k' v f -noArg :: String -> Value -> a -> Either String a-noArg _ (Atom "yes") x = Right x-noArg k v _ = Left (k ++ ": invalid parameter, expected `yes` or `no`")+noArg :: String -> Value p -> a -> Either String a+noArg _ (Atom _ "yes") x = Right x+noArg k _ _ = Left (k ++ ": invalid parameter, expected `yes` or `no`") -optArg :: String -> Value -> (Maybe String -> a) -> Either String a-optArg _ (Atom "yes") f = Right (f Nothing)+optArg :: String -> Value p -> (Maybe String -> a) -> Either String a+optArg _ (Atom _ "yes") f = Right (f Nothing) optArg k v f =   case valueString v of     Just x -> Right (f (Just x))     Nothing -> Left (k ++ ": invalid parameter") -reqArg :: String -> Value -> (String -> a) -> Either String a+reqArg :: String -> Value p -> (String -> a) -> Either String a reqArg k v f =   case valueString v of     Just x -> Right (f x)     Nothing -> Left (k ++ ": invalid parameter") -valueString              :: Value -> Maybe String-valueString (Text t)      = Just (Text.unpack t)-valueString (Number 10 n) = Just (show n)-valueString _             = Nothing+valueString                :: Value p -> Maybe String+valueString (Text _ t)      = Just (Text.unpack t)+valueString (Number _ 10 n) = Just (show n)+valueString _               = Nothing  lookupOption :: String -> [OptDescr a] -> Maybe (OptDescr a) lookupOption name = find $ \o -> name `elem` optionLongNames o