-- 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
--   <a>https://en.wikipedia.org/wiki/INI_file</a>).
@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
--   <i>sections</i>, each which can contain 0 or more <i>options</i>. Each
--   options is a <i>key</i>, <i>value</i> pair.
--   
--   This module contains the API for constructing, manipulating, and
--   querying configurations.
module Data.Ini

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

-- | Returns <tt>True</tt> 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 <tt>True</tt> 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 <a>Reader</a>.
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 <a>IniFile</a> items.
buildConfig :: [IniFile] -> IniParseResult Config

-- | Consumer of whitespace "<tt> t</tt>".
eatWhiteSpace :: Parser String

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

-- | Parser for a single line of an option. The line must start with an
--   option name, then a <tt>=</tt> 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
--   <a>eatWhiteSpace</a>).
optLineParser :: Parser IniFile

-- | Parser for an option-value continuation line. The line must start with
--   either a space or a tab character ("<tt> t</tt>"). 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 <a>optContParser</a>.)
noiseParser :: Parser IniFile
iniParser :: Parser [IniFile]
instance GHC.Show.Show Data.Ini.Reader.Internals.IniReaderError
instance GHC.Classes.Eq Data.Ini.Reader.Internals.IniReaderError
instance GHC.Classes.Eq Data.Ini.Reader.Internals.IniFile
instance GHC.Show.Show Data.Ini.Reader.Internals.IniFile


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

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