HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleini-0.5.1Haskell98

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")])]})
Contents
  1. Reading
  2. Writing
  3. Advanced writing
  4. Types
  5. Parsers
Synopsis
  • Packageini-0.5.1
  • Exports21
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceIni.hs

Reading

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

Advanced writing

Types

Parsers