HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

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:

Example1 expression
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 declarations
valuelookupValue
  1. :: Text

    Section name

  2. -> Text

    Key

  3. -> Ini
  4. -> Either String Text
#

Lookup one value in the config.

Example:

Example1 expression
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= lookupValue "SERVER" "hostname"Right "localhost"
valuelookupArray
  1. :: Text

    Section name

  2. -> Text

    Key

  3. -> Ini
  4. -> Either String [Text]
#

Lookup one value in the config.

Example:

Example1 expression
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= lookupValue "SERVER" "hostname"Right "localhost"
valuesections :: Ini -> [Text]
#

Get the sections in the config.

Example:

Example1 expression
sections <$> parseIni "[SERVER]\nport: 6667\nhostname: localhost"Right ["SERVER"]
valuekeys
  1. :: Text

    Section name

  2. -> Ini
  3. -> Either String [Text]
#

Get the keys in a section.

Example:

Example1 expression
parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>= keys "SERVER"Right ["hostname","port"]

Writing

2 declarations

Advanced writing

5 declarations

Types

2 declarations

Parsers

3 declarations