https://github.com/andreasabel/ini
Quick and easy INI configuration files for Haskell
https://github.com/andreasabel/ini
configuration haskell ini-parser
Last synced: over 1 year ago
JSON representation
Quick and easy INI configuration files for Haskell
- Host: GitHub
- URL: https://github.com/andreasabel/ini
- Owner: andreasabel
- License: other
- Created: 2022-04-16T07:15:57.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T14:18:14.000Z (over 1 year ago)
- Last Synced: 2025-03-20T19:30:54.036Z (over 1 year ago)
- Topics: configuration, haskell, ini-parser
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/ini
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://hackage.haskell.org/package/ini)
[](https://stackage.org/nightly/package/ini)
[](https://www.stackage.org/package/ini)
[](https://github.com/andreasabel/ini/actions/workflows/haskell.yml)
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:
``` ini
# Some comment.
[SERVER]
port=6667
hostname=localhost
[AUTH]
user=hello
pass=world
# Salt can be an empty string.
salt=
```
Parsing example:
``` haskell
> parseIni "[SERVER]\nport: 6667\nhostname: localhost"
Right (Ini {unIni = fromList [("SERVER",fromList [("hostname","localhost")
,("port","6667")])]})
```
Extracting values:
``` haskell
> parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>=
lookupValue "SERVER" "hostname"
Right "localhost"
```
Parsing:
``` haskell
> parseIni "[SERVER]\nport: 6667\nhostname: localhost" >>=
readValue "SERVER" "port" decimal
Right 6667
```
Import `Data.Text.Read` to use `decimal`.
## Related packages
[`ini-qq`](https://hackage.haskell.org/package/ini-qq) provides a quasiquoter for INI.