-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse config files using parsec and generate parse errors -- on unhandled keys -- -- This is yet another entry in Haskell's enourmous collection of -- config-file parsing libraries. It lacks many of the bells and whistles -- of other config-file parsing libraries, such as hierarchical sections -- and on-the-fly reloading. On the other hand, it has a combination of -- features I was unable to find in other libraries: -- -- -- -- If you don't need all of these features, there are probably better -- libraries out there for you. If you're free to use its idiosyncratic -- file format, the config-value library, in particular, is excelent. @package config-parser @version 0.1.0.5 -- | This is yet another entry in Haskell's enourmous collection of -- config-file parsing libraries. It lacks many of the bells and whistles -- of other config-file parsing libraries, such as hierarchical sections -- and on-the-fly reloading. On the other hand, it has a combination of -- features I was unable to find in other libraries: -- -- -- -- If you don't need all of these features, there are probably better -- libraries out there for you. If you're free to use its idiosyncratic -- file format, the config-value library, in particular, is excelent. -- --

Example:

-- -- By default, this library parses flat config like the following: -- --
--   a_string = "blah, blah, blah\nmore blah"
--   a_number = 9001
--   a_list   = [1,2,3,4,5]
--   # This is a comment
--   
-- -- If you wanted to parse the above file, saved as ./config.txt, -- you might do so as follows: -- --
--   import Text.ConfigParser
--   
--   cp :: ConfigParser (Maybe String, Maybe Integer, [Integer])
--   cp = configParser (Nothing, Nothing, [])
--       [ ConfigOption
--           { key    = "a_string"
--           , parser = string
--           , action = \s (_,n,ns) -> (Just s, n, ns)
--           }
--       , ConfigOption
--           { key    = "a_number"
--           , parser = integer
--           , action = \n (s,_,ns) -> (s, Just n, ns)
--           }
--       , ConfigOption
--           { key    = "a_list"
--           , parser = list integer
--           , action = \ns (s,n,_) -> (s, n, ns)
--           }
--       ]
--   
--   main :: IO ()
--   main = parseFromFile cp "./config.txt" >>= print
--   
module Text.ConfigParser type Key = String data ConfigOption c -- | Parameters for a parser that takes a config file and produces a -- c. Use the configParser_ constructor if you want to -- specify your own lineParser or commentStart. -- Otherwise, use the configParser smart constructor. data ConfigParser c -- | Smart constructor to check that options doesn't contain any -- duplicate keys before creating a ConfigParser. configParser_ :: (forall a. Key -> Parser a -> Parser a) -> [String] -> c -> [ConfigOption c] -> ConfigParser c -- | Smart constructor for a ConfigParser that uses a default syntax -- like key = value and line comments starting with #. configParser :: c -> [ConfigOption c] -> ConfigParser c -- | Default syntax like key = value. defaultKeyValue :: Key -> Parser a -> Parser a -- | Default line comment like # comment text. defaultLineCommentInit :: [String] config :: ConfigParser c -> Parser c -- | Parse a string surrounded by quotes. Quotes within the string must be -- escaped with backslashes. string :: IsString s => Parser s -- | Parse an integer. integer :: Parser Integer -- | Parse a boolean. Valid synonyms for True are true, -- yes, Yes, on, and On. Valid -- synonyms for False are false, no, -- No, off, and Off. bool :: Parser Bool -- | Parse a list of values surrounded by [ and ], and -- separated by commas. The list can contain whitespace and newlines. list :: (Parser a) -> Parser [a]