[darcs-devel] configuration records

Ben Franksen ben.franksen at online.de
Mon Mar 27 00:00:22 UTC 2017


When I re-wrote the options subsystem, I added configuration records for
a few commands (Amend and Record) to see whether this would be a good
way to handle options in the command implementations.

I no longer think this is a good idea. Here are my reasons:

(1) The data in the config record should be independent of the order of
the members. But the way the config record is constructed relies on a
very specific order, namely the same in which the options are combined.
This is error prone: swapping two neighbor options that happen to have
the same type (e.g. Bool or Maybe String) silently destroys command
configuration.

(2) The whole approach is too inflexible. For instance, it is not easy
or elegant to extract a sub-configuration for shared parts of the
command implementation. Care has to be taken to avoid name clashes.

(3) We currently expose the configuration type and make it a type
parameter for the command. This unnecessarily complicates the code. It
was not part of my original plan but turned out to be necessary, at
least until all explicit flag list manipulation is removed. I am working
on that but it takes time. In the meantime it would be nice to get the
simpler monomorphic command type back.

I am going to roll back the addition of config records to Amend and
Record and then re-monomorphize the Command type.

There is one more gripe I have with how options are currently used:

The order in which options are combined also determines the order in
which they are listed in the help. To support classification into basic
and advanced options, each command defines two combined option sets.
This is stupid: the classification should be done in the option
definition, not in the commands. I am planning to change that. As a
positive side-effect, this will allow us to (easily) define finer
classifications. For instance, I would like to group some of the common
options supported by all commands into an extra section. We could also
make a group for hidden options etc.

Cheers
Ben



More information about the darcs-devel mailing list