
On Sun, Sep 21, 2008 at 4:02 PM, Sterling Clover
Alternately, just go with a map initially with default values. Then parse the command line args into a second map (especially if they're all of a format like -argname argvalue). Then lookup your args file with the command line map, and failing that the default map. Then read the args file and finally merge all three maps in the proper order. No need for monoid instances, special data types or any of that, so at a little cost in elegance a much more succinct way to get what you want. As a final step, you can always project the map values into a record type, to get some safety for the rest of your program. The entire process, aside from creating the record, should probably be no more than four or so lines.
Yes, that's the direction I'll end up going in, I think. The idea with the monoid was nice, but I couldn't really turn it into a usable idea in my head, since the whole idea with an entity turns out to be somewhat strange. At least in the way I look at arguments. However, the idea of using a product to "merge" to configurations is interesting and I think I might explore it more when I find the time. (So far I've only identified that I probably will have use for template haskell once I decide to play more with it.) Thanks for the help and suggestions offered on the list. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe