Quick and easy INI configuration files for Haskell
Go to file
2022-07-26 00:42:17 +02:00
.github/workflows ini.cabal: new maintainer, TypeOperators, tested-with GHC 9.4.1 2022-07-25 23:50:53 +02:00
src/Data Silence warning about non-canonical mappend 2022-07-25 23:49:23 +02: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 ini.cabal: new maintainer, TypeOperators, tested-with GHC 9.4.1 2022-07-25 23:50:53 +02:00
cabal.haskell-ci ini.cabal: new maintainer, TypeOperators, tested-with GHC 9.4.1 2022-07-25 23:50:53 +02:00
CHANGELOG.md Release 0.4.2: CHANGELOG, README badges, allow latest semigroup 2022-07-26 00:42:17 +02:00
ini.cabal Release 0.4.2: CHANGELOG, README badges, allow latest semigroup 2022-07-26 00:42:17 +02:00
LICENSE First commit 2013-12-30 20:57:56 +01:00
README.md Release 0.4.2: CHANGELOG, README badges, allow latest semigroup 2022-07-26 00:42:17 +02: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

Hackage ini on Stackage Nightly Stackage LTS version Haskell CI

ini

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.