[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:45 UTC 2010
The following commit has been merged in the master branch:
commit ab8c93a1d490b00bced266f022229800e51a7e6b
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Dec 1 03:16:36 2004 +0100
More rearranging
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-130)
diff --git a/ChangeLog b/ChangeLog
index 3d74a98..334673b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-30 20:16:36 GMT John Goerzen <jgoerzen at complete.org> patch-130
+
+ Summary:
+ More rearranging
+ Revision:
+ missingh--head--0.5--patch-130
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/ConfigParser.hs
+ libsrc/MissingH/ConfigParser/Types.hs
+ testsrc/ConfigParser/Maintest.hs
+
+
2004-11-30 20:12:08 GMT John Goerzen <jgoerzen at complete.org> patch-129
Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 7742be8..4b333b0 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -37,7 +37,7 @@ module MissingH.ConfigParser
CPErrorData(..), CPError, CPResult,
-- * Initialization
-- $initialization
- empty,
+ emptyCP,
-- * Reading
-- $reading
@@ -83,13 +83,23 @@ The content contains only an empty mandatory @DEFAULT@ section.
'usedefault' is set to @True at .
-}
-empty :: ConfigParser
-empty = ConfigParser { content = fromAL [("DEFAULT", [])],
+emptyCP :: ConfigParser
+emptyCP = ConfigParser { content = fromAL [("DEFAULT", [])],
defaulthandler = defdefaulthandler,
optionxform = map toLower,
usedefault = True,
accessfunc = defaccessfunc}
+{- | Low-level tool to convert a parsed object into a 'CPData'
+representation. Performs no option conversions or special handling
+of @DEFAULT at . -}
+fromAL :: ParseOutput -> CPData
+fromAL origal =
+ let conv :: CPData -> (String, [(String, String)]) -> CPData
+ conv fm sect = addToFM fm (fst sect) (listToFM $ snd sect)
+ in
+ foldl conv emptyFM origal
+
-- internal function: default access function
defaccessfunc :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
defaccessfunc cp s o = defdefaulthandler cp s (optionxform cp $ o)
@@ -342,7 +352,7 @@ to_string cp =
{- $initialization
-The variable 'empty' is exported, and contains a default empty
+The variable 'emptyCP' is exported, and contains a default empty
'ConfigParser'.
-}
@@ -352,8 +362,8 @@ You can use these functions to read data from a file.
A common idiom for loading a new object from stratch is:
- at cp <- 'readfile' 'empty' \"\/etc\/foo.cfg\"@
+ at cp <- 'readfile' 'emptyCP' \"\/etc\/foo.cfg\"@
-Note the use of 'empty'; this will essentially cause the file's data
+Note the use of 'emptyCP'; this will essentially cause the file's data
to be merged with the empty 'ConfigParser'.
-}
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index 32661ab..5859947 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -36,7 +36,7 @@ module MissingH.ConfigParser.Types (
CPOptions, CPData,
CPErrorData(..), CPError, CPResult,
ConfigParser(..),
- fromAL, SectionSpec,
+ SectionSpec,
OptionSpec,
ParseOutput
) where
@@ -87,7 +87,7 @@ data ConfigParser = ConfigParser
content :: CPData,
-- | How to transform an option into a standard representation
optionxform :: (OptionSpec -> OptionSpec),
- -- | Function to look up an option, considering a default value.
+ -- | Function to look up an option, considering a default value
-- if 'usedefault' is True; or ignoring a default value otherwise.
-- The option specification is assumed to be already transformed.
defaulthandler :: (ConfigParser -> SectionSpec -> OptionSpec -> CPResult String),
@@ -95,17 +95,10 @@ data ConfigParser = ConfigParser
-- is found.
usedefault :: Bool,
-- | Function that is used to perform lookups, do optional
- -- interpolation, etc.
+ -- interpolation, etc. It is assumed that accessfunc
+ -- will internally call defaulthandler to do the actual work.
+ -- The option value is not assumed to be transformed.
accessfunc :: (ConfigParser -> SectionSpec -> OptionSpec -> CPResult String)
}
-{- | Low-level tool to convert a parsed object into a 'CPData'
-representation. Performs no option conversions or special handling
-of @DEFAULT at . -}
-fromAL :: ParseOutput -> CPData
-fromAL origal =
- let conv :: CPData -> (String, [(String, String)]) -> CPData
- conv fm sect = addToFM fm (fst sect) (listToFM $ snd sect)
- in
- foldl conv emptyFM origal
diff --git a/testsrc/ConfigParser/Maintest.hs b/testsrc/ConfigParser/Maintest.hs
index ed41c6f..400501d 100644
--- a/testsrc/ConfigParser/Maintest.hs
+++ b/testsrc/ConfigParser/Maintest.hs
@@ -23,7 +23,7 @@ import MissingH.Either
import Testutil
import Control.Exception
-p inp = forceEither $ readstring empty inp
+p inp = forceEither $ readstring emptyCP inp
f msg inp exp conv = TestLabel msg $ TestCase $ assertEqual "" (Right exp) (conv (p inp))
f2 msg exp res = TestLabel msg $ TestCase $ assertEqual "" exp res
f3 msg inp exp conv = TestLabel msg $ TestCase $ assertEqual "" exp (conv (p inp))
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list