inilist 0.1.0.0 → 0.2.0.0
raw patch · 3 files changed
+19/−24 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Ini.List: instance [overlap ok] Monoid (SectionName -> OptionName -> Option -> Maybe a)
- Data.Ini.List: class Value a where getValue s o = value <$> getOption s o
+ Data.Ini.List: class Value a where getValue o s = value <$> getOption o s
- Data.Ini.List: getValue :: Value a => Section -> OptionName -> Maybe a
+ Data.Ini.List: getValue :: Value a => OptionName -> Section -> Maybe a
Files
- Data/Ini/List.hs +8/−22
- UnitTest.hs +4/−0
- inilist.cabal +7/−2
Data/Ini/List.hs view
@@ -125,10 +125,10 @@ class Value a where -- | @'getValue' 'Section' 'OptionName'@ gets the value for the -- named 'Option' from the 'Section'. - getValue :: Section -> OptionName -> Maybe a+ getValue :: OptionName -> Section -> Maybe a -- The default is to just convert the current string.- getValue s o = value <$> getOption s o+ getValue o s = value <$> getOption o s -- | 'value' converts a single 'Option' 'String' into a value of -- the type of the instance.@@ -144,7 +144,7 @@ value' v' = error $ "couldn't parse '" ++ v' ++ "' as Bool" instance Value t => Value [t] where- getValue s o = Just . map value $ getOptions s o + getValue o s = Just . map value $ getOptions o s value o = [value o] instance Read t => Value t where@@ -221,26 +221,12 @@ -- and 'OptionName'. 'Nothing' as the 'SectionName' gets 'Option' values -- from the default 'Section'. get :: Value a => Config -> Maybe SectionName -> OptionName -> Maybe a-get c s o = get' s >>= (flip getValue) o where+get c s o = get' s >>= getValue o where get' (Just n) = getSection c n get' Nothing = Just $ getDefault c -- And finally, the things to update a Config---- So it turns out both types of updaters are also Monoids. Who knew?-emptyUpdate :: SectionName -> OptionName -> Option -> Maybe a-emptyUpdate _ _ _ = Nothing--mappendUpdate :: (SectionName -> OptionName -> Option -> Maybe a)- -> (SectionName -> OptionName -> Option -> Maybe a)- -> (SectionName -> OptionName -> Option -> Maybe a)-(a `mappendUpdate` b) s o v = maybe (b s o v) Just $ a s o v--instance Monoid (SectionName -> OptionName -> Option -> Maybe a) where- mempty = emptyUpdate- mappend = mappendUpdate- -- | 'updateOptions' uses an 'UpdateOption' to update all the options -- in the 'Config'. updateOptions :: UpdateOption -> Config -> Config@@ -288,11 +274,11 @@ -- Internal routines for getting options. Users should use -- getValue-getOptions :: Section -> OptionName -> [Option]-getOptions os k = map snd . filter (\(n, _) -> n == k) $ AL.toList os+getOptions :: OptionName -> Section -> [Option]+getOptions k os = map snd . filter (\(n, _) -> n == k) $ AL.toList os -getOption :: Section -> OptionName -> Maybe Option-getOption os n = AL.lookupFirst n os+getOption :: OptionName -> Section -> Maybe Option+getOption os n = AL.lookupFirst os n -- And output things
UnitTest.hs view
@@ -211,6 +211,10 @@ testCase "SectionsBy" $ ["Section 2"] @=? map fst (getSectionsBy test $ elem ' ') ],+ testGroup "value" [+ testCase "Nothing" $ (Nothing :: Maybe Int) @=? getValue "NoValue" def,+ testCase "String" $ (Just "12" :: Maybe String) @=? getValue "Value1" def+ ], testGroup "get" [ testCase "Nothing" $ (Nothing :: Maybe Int) @=? get test Nothing "NoValue", testCase "String"
inilist.cabal view
@@ -1,5 +1,5 @@ name: inilist-version: 0.1.0.0+version: 0.2.0.0 synopsis: Processing for .ini files with duplicate sections and options description: Please see README.md homepage: https://chiselapp.com/user/mwm/repository/inilist@@ -33,4 +33,9 @@ source-repository head type: fossil- location: + location: https://chiselapp.com/user/mwm/repository/inilist/++source-repository this+ type: fossil+ location: https://chiselapp.com/user/mwm/repository/inilist/+ tag: 0.2.0.0