[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 dde674b50b9aff61bd46d594d88099e09e0cc001
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Dec 1 03:12:08 2004 +0100
Moved some stuff out of CP typse that didn't belong there anyway
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-129)
diff --git a/ChangeLog b/ChangeLog
index 85b5fd6..3d74a98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-30 20:12:08 GMT John Goerzen <jgoerzen at complete.org> patch-129
+
+ Summary:
+ Moved some stuff out of CP typse that didn't belong there anyway
+ Revision:
+ missingh--head--0.5--patch-129
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/ConfigParser.hs
+ libsrc/MissingH/ConfigParser/Types.hs
+
+
2004-11-30 20:01:53 GMT John Goerzen <jgoerzen at complete.org> patch-128
Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 107b46c..7742be8 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -71,6 +71,47 @@ import System.IO(Handle)
import Data.Char
import Control.Monad.Error
+----------------------------------------------------------------------
+-- Basic types / default values
+----------------------------------------------------------------------
+
+{- | The default empty 'MissingH.ConfigParser' object.
+
+The content contains only an empty mandatory @DEFAULT@ section.
+
+'optionxform' is set to @map toLower at .
+
+'usedefault' is set to @True at .
+-}
+empty :: ConfigParser
+empty = ConfigParser { content = fromAL [("DEFAULT", [])],
+ defaulthandler = defdefaulthandler,
+ optionxform = map toLower,
+ usedefault = True,
+ accessfunc = defaccessfunc}
+
+-- internal function: default access function
+defaccessfunc :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
+defaccessfunc cp s o = defdefaulthandler cp s (optionxform cp $ o)
+
+-- internal function: default handler
+defdefaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
+
+defdefaulthandler cp sect opt =
+ let fm = content cp
+ lookup :: SectionSpec -> OptionSpec -> CPResult String
+ lookup s o = do sect <- maybeToEither (NoSection s, "get") $ lookupFM fm s
+ maybeToEither (NoOption o, "get") $ lookupFM sect o
+ trydefault :: CPError -> CPResult String
+ trydefault e = if (usedefault cp)
+ then
+ lookup "DEFAULT" opt
+ -- Use original error if it's not in DEFAULT either
+ `catchError` (\_ -> throwError e)
+ else throwError e
+ in
+ lookup sect opt `catchError` trydefault
+
{- | Combines two 'ConfigParser's into one.
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index 4520633..32661ab 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -35,7 +35,7 @@ Copyright (c) 2004 John Goerzen, jgoerzen\@complete.org
module MissingH.ConfigParser.Types (
CPOptions, CPData,
CPErrorData(..), CPError, CPResult,
- ConfigParser(..), empty,
+ ConfigParser(..),
fromAL, SectionSpec,
OptionSpec,
ParseOutput
@@ -99,42 +99,6 @@ data ConfigParser = ConfigParser
accessfunc :: (ConfigParser -> SectionSpec -> OptionSpec -> CPResult String)
}
-{- | The default empty 'MissingH.ConfigParser' object.
-
-The content contains only an empty mandatory @DEFAULT@ section.
-
-'optionxform' is set to @map toLower at .
-
-'usedefault' is set to @True at .
--}
-empty :: ConfigParser
-empty = ConfigParser { content = fromAL [("DEFAULT", [])],
- defaulthandler = defdefaulthandler,
- optionxform = map toLower,
- usedefault = True,
- accessfunc = defaccessfunc}
-
--- internal function: default access function
-defaccessfunc :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
-defaccessfunc cp s o = defdefaulthandler cp s (optionxform cp $ o)
-
--- internal function: default handler
-defdefaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult String
-
-defdefaulthandler cp sect opt =
- let fm = content cp
- lookup :: SectionSpec -> OptionSpec -> CPResult String
- lookup s o = do sect <- maybeToEither (NoSection s, "get") $ lookupFM fm s
- maybeToEither (NoOption o, "get") $ lookupFM sect o
- trydefault :: CPError -> CPResult String
- trydefault e = if (usedefault cp)
- then
- lookup "DEFAULT" opt
- -- Use original error if it's not in DEFAULT either
- `catchError` (\_ -> throwError e)
- else throwError e
- in
- lookup sect opt `catchError` trydefault
{- | Low-level tool to convert a parsed object into a 'CPData'
representation. Performs no option conversions or special handling
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list