BSD-3-Clause licensed by Chris Done
Maintained by Andreas Abel
This version can be pinned in stack with:ini-0.4.2@sha256:d49131863e2957386d228c53773c25d1262de490728c6c19b85064eb4422c3e6,1658

Module documentation for 0.4.2

Used by 1 package in nightly-2022-08-02(full list with versions):

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.

Related packages

ini-qq provides a quasiquoter for INI.

Changes

0.4.2

2022-07-26, Andreas Abel

  • Fail parsing if the input is not completely consumed #30
  • Print global values as well #28

Tested with GHC 7.0 - 9.4.1 RC1.

0.4.1

2019-01-02, Chris Done

  • Allow global section #6