[Haskell-cafe] Deriving settings from command line, environment, and files

Roman Cheplyaka roma at ro-che.info
Thu Nov 1 20:10:38 CET 2012

* David Thomas <davidleothomas at gmail.com> [2012-11-01 11:26:01-0700]
> Is there a library that provides a near-complete solution for this?
> I looked around a bit and found many (many!) partial solutions on hackage,
> but nothing that really does it all.  In coding it up for my own projects,
> however, I can't help but feel like I must be reinventing the wheel.
> What I want is something that will process command line options (this
> seems to be where most packages are targetted), environment variables,
> and settings files (possibly specified in options), and override/default
> appropriately.
> Did I miss something?
> If not, I'd like to see about fixing the situation, but very much want
> to avoid the whole "There were X libraries that didn't quite do it right;
> now there's X+1!" thing.  Are there any opinions as to which of the many
> libraries is likely the best starting point if I'm going to contribute
> to one of them?

What functionality would such a library provide?

There is a variety of good command-line parsing libraries and even more
possible configuration file formats. I don't think you want to commit to
some particular command-line syntax or config file format for the
library to be generally useful (and I don't see any benefit of doing

But then the only part that remains is just combining the settings,
which is a simple monoidal operation. Just define the data type of your
settings, define/derive a Monoid instance for it in spirit of First/Last
monoids, and then mappend them in the right order.

(I also mostly concur with what Ben wrote on this subject.)


More information about the Haskell-Cafe mailing list