Quick and easy INI configuration files for Haskell
Go to file
2022-04-16 09:18:00 +02:00
.github/workflows Activate Github workflows by vanilla CI 2022-04-16 09:18:00 +02:00
src/Data Fail parsing if the input isn't completely consumed 2021-04-26 11:47:04 -06:00
test Fail parsing if the input isn't completely consumed 2021-04-26 11:47:04 -06:00
.dir-locals.el Add .dir-locals.el 2016-01-08 12:56:46 +00:00
.gitignore Add stack.yaml 2016-01-07 07:38:46 +00:00
ini.cabal Bump to 0.4.2 2021-04-27 14:35:53 +01:00
LICENSE First commit 2013-12-30 20:57:56 +01:00
README.md Add ini-qq to the related packages 2016-07-15 11:50:29 +09:00
Setup.hs First commit 2013-12-30 20:57:56 +01:00
stack.yaml Upgrade to lts-16 2021-04-26 11:32:06 -06:00

ini Hackage

Quick and easy configuration files in the INI format for Haskell.

Format rules and recommendations:

  • foo: bar or foo=bar are allowed.
  • The : syntax is space-sensitive.
  • Keys are case-sensitive.
  • Lower-case is recommended.
  • Values can be empty.
  • Keys cannot contain :, =, [, or ].
  • Comments must start at the beginning of the line with ; or #.

An example configuration file:

# Some comment.
[SERVER]
port=6667
hostname=localhost
[AUTH]
user=hello
pass=world
# Salt can be an empty string.
salt=

Parsing example:

> parseIni "[SERVER]\nport: 6667\nhostname: localhost"
Right (Ini {unIni = fromList [("SERVER",fromList [("hostname","localhost")
                                                 ,("port","6667")])]})

Extracting values:

> parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>=
  lookupValue "SERVER" "hostname"
Right "localhost"

Parsing:

> parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>=
  readValue "SERVER" "port" decimal
Right 6667

Import Data.Text.Read to use decimal.

ini-qq provides a quasiquoter for INI.