Parse an INI file.
Moduleini-0.4.2Haskell98
Data.Ini
Clean configuration files in the INI format.
Format rules and recommendations:
The
:syntax is space-sensitive.Keys are case-sensitive.
Lower-case is recommended.
Values can be empty.
Keys cannot key separators, section delimiters, or comment markers.
Comments must start at the beginning of the line and start with
;or#.
An example configuration file:
# Some comment.
[SERVER]
port=6667
hostname=localhost
; another comment here
[AUTH]
user: hello
pass: world
salt:
Parsing example:
parseIni "[SERVER]\nport: 6667\nhostname: localhost"Right (Ini {unIni = fromList [("SERVER",fromList [("hostname","localhost"),("port","6667")])]})
- 3 types
- 18 values
- Packageini-0.4.2
- Exports21
- LanguageHaskell98
- LicenceBSD-3-Clause
- SourceIni.hs
Reading
9 declarationsParse an INI config.
Lookup one value in the config.
Example:
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= lookupValue "SERVER" "hostname"Right "localhost"
Lookup one value in the config.
Example:
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= lookupValue "SERVER" "hostname"Right "localhost"
readValue Read a value using a reader from Data.Text.Read.
readArray Read an array of values using a reader from Data.Text.Read.
Parse a value using a reader from Data.Attoparsec.Text.
Get the sections in the config.
Example:
sections <$> parseIni "[SERVER]\nport: 6667\nhostname: localhost"Right ["SERVER"]
Get the keys in a section.
Example:
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= keys "SERVER"Right ["hostname","port"]
Writing
2 declarationsPrint an INI config.
Print the INI config to a file.
Advanced writing
5 declarationsEither : or =.
Instances2Eq, Show
Eq KeySeparatorDefined in ini-0.4.2 · Data.IniShow KeySeparatorDefined in ini-0.4.2 · Data.Ini
Settings determining how an INI file is written.
Constructors
Instances1Show
Show WriteIniSettingsDefined in ini-0.4.2 · Data.Ini
The default settings for writing INI files.
Print an INI config.
Print the INI config to a file.
Types
2 declarationsAn INI configuration.
Constructors
IniiniSections :: HashMap Text [(Text, Text)]iniGlobals :: [(Text, Text)]
Parsers
3 declarationsParser for an INI.
A section. Format: [foo]. Conventionally, [FOO].
A key-value pair. Either foo: bar or foo=bar.