ConfigFile-1.1.4: Configuration file reading & writing

Copyright | Copyright (C) 2004-2008 John Goerzen
License | Either LGPL or BSD3, as specified in the COPYRIGHT file.
Maintainer | John Goerzen <jgoerzen@complete.org>
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.ConfigFile.Types

Description

Internal types for Data.ConfigFile. This module is not intended to be used directly by your programs.

Copyright (c) 2004-2008 John Goerzen, jgoerzen@complete.org

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Synopsis

- type CPOptions = Map OptionSpec String
- type CPData = Map SectionSpec CPOptions
- data CPErrorData
  - = ParseError String
  - | SectionAlreadyExists SectionSpec
  - | NoSection SectionSpec
  - | NoOption OptionSpec
  - | OtherProblem String
  - | InterpolationError String
- type CPError = (CPErrorData, String)
- data ConfigParser = ConfigParser {
  - content :: CPData
  - optionxform :: OptionSpec -> OptionSpec
  - defaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String
  - usedefault :: Bool
  - accessfunc :: ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String
  }
- type SectionSpec = String
- type OptionSpec = String
- type ParseOutput = [(String, [(String, String)])]

# Documentation

type CPOptions = Map OptionSpec String Source #

Storage of options.

type CPData = Map SectionSpec CPOptions Source #

The main data storage type (storage of sections).

PLEASE NOTE: This type is exported only for use by other modules under Data.ConfigFile. You should NEVER access the FiniteMap in a ConfigParser directly. This type may change in future releases of MissingH, which could break your programs. Please retrict yourself to the interface in `ConfigFile`.

data CPErrorData Source #

Possible ConfigParser errors.

Constructors

ParseError String | Parse error
SectionAlreadyExists SectionSpec | 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
InterpolationError String | Raised by `interpolatingAccess` if a request was made for a non-existant option

#### Instances

Instances details

Eq CPErrorData Source # |
Instance details Defined in Data.ConfigFile.Types Methods (==) :: CPErrorData -> CPErrorData -> Bool (/=) :: CPErrorData -> CPErrorData -> Bool
Ord CPErrorData Source # |
Instance details Defined in Data.ConfigFile.Types Methods compare :: CPErrorData -> CPErrorData -> Ordering (<) :: CPErrorData -> CPErrorData -> Bool (<=) :: CPErrorData -> CPErrorData -> Bool (>) :: CPErrorData -> CPErrorData -> Bool (>=) :: CPErrorData -> CPErrorData -> Bool max :: CPErrorData -> CPErrorData -> CPErrorData min :: CPErrorData -> CPErrorData -> CPErrorData
Show CPErrorData Source # |
Instance details Defined in Data.ConfigFile.Types Methods showsPrec :: Int -> CPErrorData -> ShowS show :: CPErrorData -> String showList :: [CPErrorData] -> ShowS
Error CPError Source # |
Instance details Defined in Data.ConfigFile.Types Methods noMsg :: CPError strMsg :: String -> CPError

type CPError = (CPErrorData, String) Source #

Indicates an error occurred. The String is an explanation of the location of the error.

data ConfigParser Source #

This is the main record that is used by `ConfigFile`.

Constructors

ConfigParser |

Fields

- content :: CPData

  The data itself

- optionxform :: OptionSpec -> OptionSpec

  How to transform an option into a standard representation

- defaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String

  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.

- usedefault :: Bool

  Whether or not to seek out a default action when no match is found.

- accessfunc :: ConfigParser -> SectionSpec -> OptionSpec -> Either CPError String

  Function that is used to perform lookups, do optional interpolation, etc. It is assumed that accessfunc will internally call defaulthandler to do the underlying lookup. The option value is not assumed to be transformed.

type SectionSpec = String Source #

Names of sections

type OptionSpec = String Source #

Names of options

type ParseOutput = [(String, [(String, String)])] Source #

Internal output from parser