-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | ini configuration files
--   
--   Library for reading and writing configuration files in INI format (see
--   https://en.wikipedia.org/wiki/INI_file).
@package hsini
@version 0.5.2.2

module Data.Ini.Types
type Config = Map SectionName Section
type SectionName = String
type Section = Map OptionName OptionValue
type OptionName = String
type OptionValue = String
cfgFromList :: [(SectionName, [(OptionName, OptionValue)])] -> Config
cfgToList :: Config -> [(SectionName, [(OptionName, OptionValue)])]

-- | A representation of configuration options. It consists of
--   sections, each which can contain 0 or more options. Each
--   options is a key, value pair.
--   
--   This module contains the API for constructing, manipulating, and
--   querying configurations.
module Data.Ini

-- | Constructs an empty configuration.
emptyConfig :: Config

-- | Returns True iff the configuration has a section with that
--   name.
hasSection :: SectionName -> Config -> Bool

-- | Returns the section with the given name if it exists in the
--   configuration.
getSection :: SectionName -> Config -> Maybe Section

-- | Returns a list of the names of all section.
sections :: Config -> [SectionName]

-- | Removes the section if it exists.
delSection :: SectionName -> Config -> Config

-- | Returns True if the names section has the option.
hasOption :: SectionName -> OptionName -> Config -> Bool

-- | Returns the value of the option, if it exists.
getOption :: SectionName -> OptionName -> Config -> Maybe OptionValue

-- | Returns a list of all options in the section.
options :: SectionName -> Config -> [OptionName]

-- | Sets the value of the option, adding it if it doesn't exist.
setOption :: SectionName -> OptionName -> OptionValue -> Config -> Config

-- | Removes the option if it exists. Empty sections are pruned.
delOption :: SectionName -> OptionName -> Config -> Config

-- | Returns all options and their values of a section.
allItems :: SectionName -> Config -> [(OptionName, OptionValue)]

-- | Internal functions used in Reader.
module Data.Ini.Reader.Internals
data IniReaderError
IniParserError :: String -> IniReaderError
IniSyntaxError :: String -> IniReaderError
IniOtherError :: String -> IniReaderError
type IniParseResult = Either IniReaderError

-- | The type used to represent a line of a config file.
data IniFile
SectionL :: String -> IniFile
OptionL :: String -> String -> IniFile
OptionContL :: String -> IniFile
CommentL :: IniFile

-- | Build a configuration from a list of IniFile items.
buildConfig :: [IniFile] -> IniParseResult Config

-- | Consumer of whitespace " t".
eatWhiteSpace :: Parser String

-- | Parser for the start-of-section line. It expects the line to start
--   with a [ then find the section name, and finally a
--   ]. The section name may be surrounded by any number of white
--   space characters (see eatWhiteSpace).
secParser :: Parser IniFile

-- | Parser for a single line of an option. The line must start with an
--   option name, then a = must be found, and finally the rest of
--   the line is taken as the option value. The equal sign may be
--   surrounded by any number of white space characters (see
--   eatWhiteSpace).
optLineParser :: Parser IniFile

-- | Parser for an option-value continuation line. The line must start with
--   either a space or a tab character (" t"). Everything else on
--   the line, until the newline character, is taken as the continuation of
--   an option value.
optContParser :: Parser IniFile

-- | Parser for "noise" in the configuration file, such as comments and
--   empty lines. (Note that lines containing only space characters will be
--   successfully parsed by optContParser.)
noiseParser :: Parser IniFile
iniParser :: Parser [IniFile]
instance GHC.Classes.Eq Data.Ini.Reader.Internals.IniFile
instance GHC.Classes.Eq Data.Ini.Reader.Internals.IniReaderError
instance GHC.Internal.Show.Show Data.Ini.Reader.Internals.IniFile
instance GHC.Internal.Show.Show Data.Ini.Reader.Internals.IniReaderError

-- | Parser for configurations.
module Data.Ini.Reader

-- | Parser for a configuration contained in a String.
parse :: String -> IniParseResult Config
data IniReaderError
IniParserError :: String -> IniReaderError
IniSyntaxError :: String -> IniReaderError
IniOtherError :: String -> IniReaderError
type IniParseResult = Either IniReaderError
