[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:33 UTC 2010
The following commit has been merged in the master branch:
commit 3aabbc65f7e01b52c50b48d454a12c30b8bff958
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Nov 30 00:08:18 2004 +0100
Checkpointing compile success with new error code
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-114)
diff --git a/ChangeLog b/ChangeLog
index 06a8737..4158fa8 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 17:08:18 GMT John Goerzen <jgoerzen at complete.org> patch-114
+
+ Summary:
+ Checkpointing compile success with new error code
+ Revision:
+ missingh--head--0.5--patch-114
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/ConfigParser.hs
+ libsrc/MissingH/ConfigParser/Types.hs
+
+
2004-11-29 16:55:59 GMT John Goerzen <jgoerzen at complete.org> patch-113
Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index f52fb98..9858cbf 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -66,6 +66,7 @@ import Data.FiniteMap
import Data.List
import System.IO(Handle)
import Data.Char
+import Control.Monad.Error
{- | Combines two 'ConfigParser's into one.
@@ -162,7 +163,7 @@ options :: ConfigParser -> SectionSpec -> CPResult [OptionSpec]
options cp x = maybeToEither (NoSection x) $
do
o <- lookupFM (content cp) x
- keysFM o (content cp) x
+ return $ keysFM o
{- | Indicates whether the given option is present. Returns True
only if the given section is present AND the given option is present
@@ -171,9 +172,10 @@ exception could be raised.
-}
has_option :: ConfigParser -> SectionSpec -> OptionSpec -> Bool
has_option cp s o =
- let c = content cp in
+ let c = content cp
v = do secthash <- lookupFM c s
return $ elemFM (optionxform cp $ o) secthash
+ in
case v of
Nothing -> False
Just x -> x
@@ -208,7 +210,7 @@ getbool cp s o =
"no" -> return False
"off" -> return False
"disabled" -> return False
- _ -> throwError (ParseError "getbool: couldn't parse " ++
+ _ -> throwError (ParseError $ "getbool: couldn't parse " ++
val ++ " from " ++ s ++ "/" ++ o)
{- | Returns a list of @(optionname, value)@ pairs representing the content
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index 947b3ab..351b780 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -34,7 +34,7 @@ Copyright (c) 2004 John Goerzen, jgoerzen\@complete.org
module MissingH.ConfigParser.Types (
CPOptions, CPData,
- CPError, CPResult,
+ CPError(..), CPResult,
ConfigParser(..), empty,
fromAL, SectionSpec,
OptionSpec,
@@ -62,8 +62,13 @@ data CPError = ParseError String -- ^ Parse error
| SectionAlreadyExists String -- ^ 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
deriving (Eq, Ord, Show)
+instance Error CPError where
+ noMsg = OtherProblem ""
+ strMsg x = OtherProblem x
+
{- | Basic ConfigParser error handling. The Left value indicates
an error, while a Right value indicates success. -}
type CPResult = Either CPError
@@ -112,13 +117,17 @@ defdefaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult Strin
defdefaulthandler cp sect opt =
let fm = content cp
+ lookup :: SectionSpec -> OptionSpec -> CPResult String
lookup s o = do sect <- maybeToEither (NoSection s) $ lookupFM fm s
maybeToEither (NoOption o) $ lookupFM sect o
+ trydefault :: CPError -> CPResult String
trydefault e = if (usedefault cp)
then lookup "DEFAULT" opt
- else e
+ else Left e
in
- lookup sect opt `catchError` trydefault
+ case lookup sect opt of
+ Right x -> Right x
+ Left x -> trydefault x
{-
defdefaulthandler cp sect opt =
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list