ConfigFile 1.1.1 → 1.1.2
raw patch · 2 files changed
+14/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ConfigFile.cabal +1/−1
- src/Data/ConfigFile.hs +13/−2
ConfigFile.cabal view
@@ -1,5 +1,5 @@ Name: ConfigFile-Version: 1.1.1+Version: 1.1.2 License: LGPL Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen
src/Data/ConfigFile.hs view
@@ -430,8 +430,19 @@ instance Read t => Get_C t where get = genericget +-- Based on code from Neil Mitchell's safe-0.3.3 package.+readMaybe :: Read a => String -> Maybe a+readMaybe s = case [x | (x, t) <- reads s, ("","") <- lex t] of+ [x] -> Just x+ _ -> Nothing+ genericget :: (Read b, MonadError CPError m) => ConfigParser -> SectionSpec -> OptionSpec -> m b-genericget cp s o = get cp s o >>= return . read+genericget cp s o = do+ val <- get cp s o+ let errMsg = "couldn't parse value " ++ val ++ " from " ++ formatSO s o+ maybe (throwError (ParseError errMsg, "genericget"))+ return+ $ readMaybe val getbool :: MonadError CPError m => ConfigParser -> SectionSpec -> OptionSpec -> m Bool@@ -797,7 +808,7 @@ >main = do > rv <- runErrorT $ > do-> cp <- join $ liftIO $ readfile empty "/etc/passwd"+> cp <- join $ liftIO $ readfile emptyCP "/etc/passwd" > let x = cp > liftIO $ putStrLn "In the test" > nb <- get x "DEFAULT" "nobody"