module Data.ConfigFile.Types (
CPOptions, CPData,
CPErrorData(..), CPError,
ConfigParser(..),
SectionSpec,
OptionSpec,
ParseOutput
) where
import qualified Data.Map as Map
import Data.Char
import Control.Monad.Error
type ParseOutput = [(String, [(String, String)])]
type SectionSpec = String
type OptionSpec = String
type CPOptions = Map.Map OptionSpec String
type CPData = Map.Map SectionSpec CPOptions
data CPErrorData = ParseError String
| SectionAlreadyExists SectionSpec
| NoSection SectionSpec
| NoOption OptionSpec
| OtherProblem String
| InterpolationError String
deriving (CPErrorData -> CPErrorData -> Bool
(CPErrorData -> CPErrorData -> Bool)
-> (CPErrorData -> CPErrorData -> Bool) -> Eq CPErrorData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CPErrorData -> CPErrorData -> Bool
$c/= :: CPErrorData -> CPErrorData -> Bool
== :: CPErrorData -> CPErrorData -> Bool
$c== :: CPErrorData -> CPErrorData -> Bool
Eq, Eq CPErrorData
Eq CPErrorData
-> (CPErrorData -> CPErrorData -> Ordering)
-> (CPErrorData -> CPErrorData -> Bool)
-> (CPErrorData -> CPErrorData -> Bool)
-> (CPErrorData -> CPErrorData -> Bool)
-> (CPErrorData -> CPErrorData -> Bool)
-> (CPErrorData -> CPErrorData -> CPErrorData)
-> (CPErrorData -> CPErrorData -> CPErrorData)
-> Ord CPErrorData
CPErrorData -> CPErrorData -> Bool
CPErrorData -> CPErrorData -> Ordering
CPErrorData -> CPErrorData -> CPErrorData
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CPErrorData -> CPErrorData -> CPErrorData
$cmin :: CPErrorData -> CPErrorData -> CPErrorData
max :: CPErrorData -> CPErrorData -> CPErrorData
$cmax :: CPErrorData -> CPErrorData -> CPErrorData
>= :: CPErrorData -> CPErrorData -> Bool
$c>= :: CPErrorData -> CPErrorData -> Bool
> :: CPErrorData -> CPErrorData -> Bool
$c> :: CPErrorData -> CPErrorData -> Bool
<= :: CPErrorData -> CPErrorData -> Bool
$c<= :: CPErrorData -> CPErrorData -> Bool
< :: CPErrorData -> CPErrorData -> Bool
$c< :: CPErrorData -> CPErrorData -> Bool
compare :: CPErrorData -> CPErrorData -> Ordering
$ccompare :: CPErrorData -> CPErrorData -> Ordering
$cp1Ord :: Eq CPErrorData
Ord, Int -> CPErrorData -> ShowS
[CPErrorData] -> ShowS
CPErrorData -> String
(Int -> CPErrorData -> ShowS)
-> (CPErrorData -> String)
-> ([CPErrorData] -> ShowS)
-> Show CPErrorData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CPErrorData] -> ShowS
$cshowList :: [CPErrorData] -> ShowS
show :: CPErrorData -> String
$cshow :: CPErrorData -> String
showsPrec :: Int -> CPErrorData -> ShowS
$cshowsPrec :: Int -> CPErrorData -> ShowS
Show)
type CPError = (CPErrorData, String)
instance Error CPError where
noMsg :: CPError
noMsg = (String -> CPErrorData
OtherProblem String
"", String
"")
strMsg :: String -> CPError
strMsg String
x = (String -> CPErrorData
OtherProblem String
x, String
"")
data ConfigParser = ConfigParser
{
ConfigParser -> CPData
content :: CPData,
ConfigParser -> ShowS
optionxform :: (OptionSpec -> OptionSpec),
ConfigParser
-> ConfigParser -> String -> String -> Either CPError String
defaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String,
ConfigParser -> Bool
usedefault :: Bool,
ConfigParser
-> ConfigParser -> String -> String -> Either CPError String
accessfunc :: (ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String)
}