[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:48:35 UTC 2010


The following commit has been merged in the master branch:
commit f45bf4adc72456aed2db14c057f8ad3830215b0c
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Nov 30 03:17:08 2004 +0100

    Doc fixes
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-117)

diff --git a/ChangeLog b/ChangeLog
index 972ca17..7259f97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-11-29 20:17:08 GMT	John Goerzen <jgoerzen at complete.org>	patch-117
+
+    Summary:
+      Doc fixes
+    Revision:
+      missingh--head--0.5--patch-117
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/ConfigParser.hs
+     libsrc/MissingH/ConfigParser/Types.hs
+
+
 2004-11-29 20:00:23 GMT	John Goerzen <jgoerzen at complete.org>	patch-116
 
     Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index d410ad8..06379a9 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -34,7 +34,7 @@ module MissingH.ConfigParser
     (
      -- * Types
      SectionSpec, OptionSpec, ConfigParser(..),
-     CPError, CPResult,
+     CPErrorData(..), CPError, CPResult,
      -- * Initialization
      -- $initialization
      empty,
@@ -151,7 +151,8 @@ No special @DEFAULT@ processing is done. -}
 has_section :: ConfigParser -> SectionSpec -> Bool
 has_section cp x = elemFM x (content cp)
 
-{- | Adds the specified section name.  Raises an exception if the
+{- | Adds the specified section name.  Returns a
+'SectionAlreadyExists' error if the
 section was already present.  Otherwise, returns the new 
 'ConfigParser' object.-}
 add_section :: ConfigParser -> SectionSpec -> CPResult ConfigParser
@@ -174,7 +175,7 @@ options cp x = maybeToEither (NoSection x, "options") $
 {- | Indicates whether the given option is present.  Returns True
 only if the given section is present AND the given option is present
 in that section.  No special @DEFAULT@ processing is done.  No
-exception could be raised.
+exception could be raised or error returned.
 -}
 has_option :: ConfigParser -> SectionSpec -> OptionSpec -> Bool
 has_option cp s o = 
@@ -188,13 +189,14 @@ has_option cp s o =
                            
 {- | Retrieves a string from the configuration file.
 
-Returns an error if no such section/option could be found.
+Returns an error if no such section\/option could be found.
 -}
 get :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
 get cp = (accessfunc cp) cp
 
 {- | Retrieves a string from the configuration file and attempts to parse it
-as a number.  Raises an exception if no such option could be found or if 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. -}
 getnum :: (Read a, Num a) => ConfigParser -> SectionSpec -> OptionSpec -> CPResult a
 getnum cp s o = get cp s o >>= return . read
@@ -203,7 +205,35 @@ getnum cp s o = get cp s o >>= return . read
 it as a boolean.  
 
 Returns an error if no such option could be found or
-if it could not be parsed as a boolean. -}
+if it could not be parsed as a boolean.
+
+Strings are case-insentively converted as follows:
+
+The following will produce a True value:
+
+ * 1
+
+ * yes
+
+ * on
+
+ * enabled
+
+ * true
+
+The following will produce a False value:
+
+ * 0
+
+ * no
+
+ * off
+
+ * disabled
+
+ *false
+
+ -}
 getbool :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult Bool
 getbool cp s o = 
     do val <- get cp s o
@@ -212,10 +242,12 @@ getbool cp s o =
                   "yes" -> return True
                   "on" -> return True
                   "enabled" -> return True
+                  "true" -> return True
                   "0" -> return False
                   "no" -> return False
                   "off" -> return False
                   "disabled" -> return False
+                  "false" -> return False
                   _ -> throwError (ParseError $ "couldn't parse bool " ++
                                    val ++ " from " ++ s ++ "/" ++ o, "getbool")
 
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index 1572de4..8f08719 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -62,7 +62,7 @@ type CPData = FiniteMap SectionSpec CPOptions
 
 {- | Possible ConfigParser errors. -}
 data CPErrorData = ParseError String        -- ^ Parse error
-                 | SectionAlreadyExists String -- ^ Attempt to create an already-existing ection
+                 | SectionAlreadyExists SectionSpec -- ^ Attempt to create an already-existing ection
                  | NoSection SectionSpec    -- ^ The section does not exist
                  | NoOption OptionSpec      -- ^ The option does not exist
                  | OtherProblem String      -- ^ Miscellaneous error
@@ -70,9 +70,7 @@ data CPErrorData = ParseError String        -- ^ Parse error
 
 {- | Indicates an error occurred.  The String is an explanation of the location
 of the error. -}
-type CPError = (CPErrorData -- ^ The error itself
-               , String -- ^ Where it occurred
-               )
+type CPError = (CPErrorData, String)
 
 instance Error CPError where
     noMsg = (OtherProblem "", "")

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list