Safe Haskell | None |
---|---|
Language | Haskell2010 |
A simplified library for reading configuration files in the format of configurator-ng.
Synopsis
- type Key = Text
- data Value
- type Config = Map Key Value
- load :: FilePath -> IO Config
- newtype ParseError = ParseError Text
- data Parser a b
- runParser :: Parser a b -> a -> Either Text b
- bool :: Parser Value Bool
- int :: Parser Value Int
- string :: Parser Value Text
- value :: Parser Value Value
- list :: Parser Value a -> Parser Value [a]
- optional :: Key -> Parser Value a -> Parser Config (Maybe a)
- required :: Key -> Parser Value a -> Parser Config a
- subassocs :: Key -> Parser Value a -> Parser Config [(Key, a)]
Types
A general right-hand side value of a configuration binding.
Bool Bool | A Boolean. Represented in a configuration file as |
String Text | A Unicode string. Represented in a configuration file as text surrounded by double quotes. Escape sequences:
|
Number Scientific | A number. |
List [Value] | A heterogeneous list. Represented in a configuration
file as an opening square bracket " |
Low-level parsing
load :: FilePath -> IO Config Source #
Read and parse a configuration file.
This may cause IO exceptions for reading this file or
imported files, and ParseError
if there is a problem
with parsing or evaluating the file.
newtype ParseError Source #
An error that occurred during the low-level parsing of a configuration file.
Instances
Show ParseError Source # | |
Defined in Data.Configurator.Types showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |
Exception ParseError Source # | |
Defined in Data.Configurator.Types toException :: ParseError -> SomeException # fromException :: SomeException -> Maybe ParseError # displayException :: ParseError -> String # |
High-level parsing
A generic parser.
A
knows how to extract a Parser
a bb
from an a
. Typical
instances are
, which handles the parsing of
individual configuration values, and Parser
Value
a
, which
handles extracting data from a full keyed configuration file.Parser
Config
a
Value parsers
bool :: Parser Value Bool Source #
Extract a boolean value.
bool
expects the given value to be boolean.
string :: Parser Value Text Source #
Extract a string value.
string
expects the given value to be a string.
value :: Parser Value Value Source #
Extract a raw value.
value
returns a configuration value in its raw form.
list :: Parser Value a -> Parser Value [a] Source #
Parse a list of values.
expects a list value, and parses each entry with list
pp
.