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


The following commit has been merged in the master branch:
commit c8807a5037082ced77a838f231aedede0fb4c249
Author: John Goerzen <jgoerzen at complete.org>
Date:   Fri Dec 3 01:54:22 2004 +0100

    Updated docs
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-142)

diff --git a/ChangeLog b/ChangeLog
index 8df8a42..363abd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-12-02 18:54:22 GMT	John Goerzen <jgoerzen at complete.org>	patch-142
+
+    Summary:
+      Updated docs
+    Revision:
+      missingh--head--0.5--patch-142
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/ConfigParser.hs
+     libsrc/MissingH/ConfigParser/Types.hs
+
+
 2004-12-01 20:42:42 GMT	John Goerzen <jgoerzen at complete.org>	patch-141
 
     Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 0e100a5..668a36a 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -55,6 +55,9 @@ module MissingH.ConfigParser
      -- ** Case Sensitivity
      -- $casesens
 
+     -- ** Interpolation
+     -- $interpolation
+
      -- * Usage Examples
      -- $usage
 
@@ -151,8 +154,48 @@ fromAL origal =
 simpleAccess :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
 simpleAccess cp s o = defdefaulthandler cp s (optionxform cp $ o)
 
-{- | Interpolating access function -}
-interpolatingAccess :: Int ->           -- ^ Maximum interpolation depth
+{- | Interpolating access function.  Please see the Interpolation section
+above for a background on interpolation.
+
+Although the format string looks similar to one used by "MissingH.Printf",
+it is not the same.  In particular, only the %(...)s format is supported.
+No width specifiers are supported and no conversions other than s are supported.
+
+To use this function, you must specify a maximum recursion depth for
+interpolation.  This is used to prevent a stack overflow in the event that
+the configuration file contains an endless interpolation loop.  Values of 10
+or so are usually more than enough, though you could probably go into the
+hundreds or thousands before you have actual problems.
+
+A value less than one will cause an instant error every time you attempt
+a lookup.
+
+This access method can cause 'get' and friends to return a new 'CPError':
+'InterpolationError'.  This error would be returned when:
+
+ * The configuration file makes a reference to an option that does
+   not exist
+
+ * The maximum interpolation depth is exceeded
+
+ * There is a syntax error processing a %-directive in the configuration
+   file
+
+An interpolation lookup name specifies an option only.  There is no provision
+to specify a section.  Interpolation variables are looked up in the current
+section, and, if 'usedefault' is True, in @DEFAULT@ according to the normal
+logic.
+
+To use a literal percent sign, you must place @%%@ in the configuration
+file when interpolation is used.
+
+Here is how you might enable interpolation:
+
+>let cp2 = cp {accessfunc = interpolatingAccess 10}
+
+The @cp2@ object will now support interpolation with a maximum depth of 10.
+ -}
+interpolatingAccess :: Int ->
                        ConfigParser -> SectionSpec -> OptionSpec
                        -> CPResult String
 interpolatingAccess maxdepth cp s o =
@@ -609,6 +652,30 @@ comment character at the start of the line.
 By default, section names are case-sensitive but option names are
 not. The latter can be adjusted by adjusting 'optionxform'.  -}
 
+{- $interpolation
+
+Interpolation is an optional feature, disabled by default.  If you replace
+the default 'accessfunc' ('simpleAccess') with 'interpolatingAccess',
+then you get interpolation support with 'get' and the other 'get'-based functions.
+
+As an example, consider the following file:
+
+>arch = i386
+>project = test
+>filename = test_%(arch)s.c
+>dir = /usr/src/%(filename)s 
+>percent = 5%% 
+
+With interpolation, you would get these results:
+
+>get cp "DEFAULT" "filename" -> "test_i386.c"
+>get cp "DEFAULT" "dir" -> "/usr/src/test_i386.c"
+>get cp "DEFAULT" "percent" -> "5%"
+
+For more details on interpolation, please see the documentation for the
+'interpolatingAccess' function.
+-}
+
 {- $usage
 
 The basic theory of working with ConfigParser is this:
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index 0bde483..d362073 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -86,7 +86,7 @@ instance Error CPError where
 
 {- | Basic ConfigParser error handling.  The Left value indicates
 an error, while a Right value indicates success. -}
-type CPResult a = MonadError CPError m => m a
+type CPResult a = forall m. MonadError CPError m => m a
 
 {- | This is the main record that is used by 'MissingH.ConfigParser'.
 -}

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list