[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:49:22 UTC 2010
The following commit has been merged in the master branch:
commit 539bc021aa2ffacefe76bdd0aee3c191af1d256e
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Dec 3 22:48:59 2004 +0100
Cleanup after integrating Einar's patches
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-4)
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 1f3e4e4..63ea07e 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -89,7 +89,7 @@ module MissingH.ConfigParser
readfile, readhandle, readstring,
-- * Accessing Data
- get, getbool, getnum,
+ Get_C(..),
sections, has_section,
options, has_option,
items,
@@ -371,39 +371,23 @@ has_option cp s o =
return $ elemFM (optionxform cp $ o) secthash
in maybe False id v
-
-class Get_C a where
- get :: MonadError CPError m => ConfigParser -> SectionSpec -> OptionSpec -> m a
-
-{- | Retrieves a string from the configuration file.
-
-Returns an error if no such section\/option could be found.
+{- | The class representing the data types that can be returned by "get".
-}
-instance Get_C String where
- get cp s o = eitherToMonadError $ (accessfunc cp) cp s o
-
-instance Get_C Bool where
- get = getbool
+class Get_C a where
+ {- | Retrieves a string from the configuration file.
-instance Read t => Get_C t where
- get cp s o = get cp s o >>= return . read
+When used in a context where a String is expected, returns that string verbatim.
-{- | Retrieves a string from the configuration file and attempts to parse it
-as a number. Returns an error if no such option could be found.
-An exception may be raised if it
-could not be parsed as the destination number. -}
--- FIXME delete this
-getnum :: (Read a, Num a, MonadError CPError m) =>
- ConfigParser -> SectionSpec -> OptionSpec -> m a
-getnum cp s o = get cp s o >>= return . read
+When used in a context where a Bool is expected, parses the string to
+a Boolean value (see logic below).
-{- | Retrieves a string from the configuration file and attempts to parse
-it as a boolean.
+When used in a context where anything that is an instance of Read is expected,
+calls read to parse the item.
-Returns an error if no such option could be found or
-if it could not be parsed as a boolean.
+An error will be returned of no such option could be found or if it could
+not be parsed as a boolean (when returning a Bool).
-Strings are case-insentively converted as follows:
+When parsing to a Bool, strings are case-insentively converted as follows:
The following will produce a True value:
@@ -427,10 +411,18 @@ The following will produce a False value:
* disabled
- *false
+ * false -}
+ get :: MonadError CPError m => ConfigParser -> SectionSpec -> OptionSpec -> m a
+
+instance Get_C String where
+ get cp s o = eitherToMonadError $ (accessfunc cp) cp s o
+
+instance Get_C Bool where
+ get = getbool
+
+instance Read t => Get_C t where
+ get cp s o = get cp s o >>= return . read
- -}
--- FIXME don't export
getbool :: MonadError CPError m =>
ConfigParser -> SectionSpec -> OptionSpec -> m Bool
getbool cp s o =
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list