config-ini 0.2.0.1 → 0.2.1.0
raw patch · 3 files changed
+17/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- config-ini.cabal +1/−1
- src/Data/Ini/Config.hs +10/−7
CHANGELOG.md view
@@ -1,3 +1,9 @@+0.2.1.0+=======++- Fix regression in standard API where values would be reported with+ extraneous whitespace+ 0.2.0.1 =======
config-ini.cabal view
@@ -1,5 +1,5 @@ name: config-ini-version: 0.2.0.1+version: 0.2.1.0 synopsis: A library for simple INI-based configuration files. homepage: https://github.com/aisamanra/config-ini bug-reports: https://github.com/aisamanra/config-ini/issues
src/Data/Ini/Config.hs view
@@ -203,6 +203,9 @@ " in section " ++ show sec) Just x -> return x +getVal :: IniValue -> Text+getVal = T.strip . vValue+ -- | Retrieve a field, failing if it doesn't exist, and return its raw value. -- -- >>> parseIniFile "[MAIN]\nx = hello\n" $ section "MAIN" (field "x")@@ -210,7 +213,7 @@ -- >>> parseIniFile "[MAIN]\nx = hello\n" $ section "MAIN" (field "y") -- Left "Missing field \"y\" in section \"MAIN\"" field :: Text -> SectionParser Text-field name = SectionParser $ vValue `fmap` rawField name+field name = SectionParser $ getVal `fmap` rawField name -- | Retrieve a field and use the supplied parser to parse it as a value, -- failing if the field does not exist, or if the parser fails to@@ -226,7 +229,7 @@ fieldOf name parse = SectionParser $ do sec <- getSectionName val <- rawField name- case parse (vValue val) of+ case parse (getVal val) of Left err -> addLineInformation (vLineNo val) sec (throw err) Right x -> return x @@ -237,7 +240,7 @@ -- >>> parseIniFile "[MAIN]\nx = hello\n" $ section "MAIN" (fieldMb "y") -- Right Nothing fieldMb :: Text -> SectionParser (Maybe Text)-fieldMb name = SectionParser $ fmap vValue `fmap` rawFieldMb name+fieldMb name = SectionParser $ fmap getVal `fmap` rawFieldMb name -- | Retrieve a field and parse it according to the given parser, returning -- @Nothing@ if it does not exist. If the parser fails, then this will@@ -255,7 +258,7 @@ mb <- rawFieldMb name case mb of Nothing -> return Nothing- Just v -> case parse (vValue v) of+ Just v -> case parse (getVal v) of Left err -> addLineInformation (vLineNo v) sec (throw err) Right x -> return (Just x) @@ -269,7 +272,7 @@ fieldDef name def = SectionParser $ ExceptT $ \m -> case lkp (normalize name) (isVals m) of Nothing -> return def- Just x -> return (vValue x)+ Just x -> return (getVal x) -- | Retrieve a field, parsing it according to the given parser, and returning -- a default value if it does not exist. If the parser fails, then this will@@ -287,7 +290,7 @@ mb <- rawFieldMb name case mb of Nothing -> return def- Just v -> case parse (vValue v) of+ Just v -> case parse (getVal v) of Left err -> addLineInformation (vLineNo v) sec (throw err) Right x -> return x @@ -395,7 +398,7 @@ -- >>> listWithSeparator ":" string "/bin:/usr/bin" :: Either String [FilePath] -- Right ["/bin","/usr/bin"] -- >>> listWithSeparator "," number "7 8 9" :: Either String [Int]--- Left "Unable to parse \"2 3 4\" as a value of type Int"+-- Left "Unable to parse \"7 8 9\" as a value of type Int" listWithSeparator :: (IsList l) => Text -> (Text -> Either String (Item l))