I need a set of key-value pairs for configuration read in from a file. I tried using show on a Data.Map and it doesn't look at all like what I want. It seems this is something many others might have already done so I'm wondering if there is a standard way to do it and what library to use.
-
taotree: Not sure if you, the asker, are informed about edits, so... "I've recently used configurator - which was easy enough. I suggest you try that one!" It really is simple and full featured. – Thomas M. DuBuisson Nov 30 '11 at 05:52
4 Answers
- Go to hackage.
- Click on "packages"
- Search for "config".
- Notice ConfigFile(TH), EEConfig, and tconfig.
- Read the Haddock documentation
- Select a couple and implement your task.
- Blog about your findings so the rest of us can learn from your new found expertise (thanks!).
EDIT: I've recently used configurator - which was easy enough. I suggest you try that one!
(Yes, yes. If I took my own advice I would have made a blog for you all)

- 64,245
- 7
- 109
- 166
-
6"Read the docs" - I find that one very hard when learning haskell. – matthias krull Dec 26 '11 at 14:55
-
1Thank you man! <- Sounds a bit harsh, but I appreciate that you wrote the process how to do that, so we have a solution for same kind of problems :-). – peni4142 Feb 05 '21 at 08:42
-
Glad you found it useful @peni4142. These days I'm mostly using dhall for internal configurations and tomland for things that need to be shared publicly (a toml parser). – Thomas M. DuBuisson Feb 06 '21 at 06:01
The configuration category on Hackage should list all relevant libraries: http://hackage.haskell.org/packages/#cat:Configuration
I have researched the topic myself now, and my conclusion is:
- configurator is very good, but it's currently only for user-edited configurations. The application only reads the configuration and cannot modify it. So it's more for server-side applications.
- tconfig has a a simple API and looked like it was what I wanted, maybe a bit raw, until I realized it's unmaintained and that some commits which are really important to use the app are applied on github but the hackage package was not updated
Other solutions didn't look like they'd work for me, I didn't like the API, but every application (and tastes) are different.
I think using JSON for instance is not a good solution because at least with Aeson when you add new settings in a new release, the old JSON without the new member from the previous version won't load. Also, i find that solution a bit verbose.
The conclusion of my research is that I wrote my own library, app-settings, which aims to be key-value, read-write, with a as succint and type-safe API as possible. And you'll find it also in the hackage links for the configurations category that I gave.
So to summarize, I think configurator is the standard for read-only configurations (and it's very powerful too, you can split the configuration file with imports for instance). For read-write there are many small libraries, some unmaintained, and no real standard I think.
UPDATE 2018 be sure to look at dhall

- 9,008
- 3
- 65
- 81
I'd also suggest just using Text.JSON
or one of the yaml libraries available (I prefer JSON myself, but...).

- 38,665
- 7
- 99
- 204