<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 1:14 PM, Eric Kow <span dir="ltr"><<a href="mailto:kowey@darcs.net">kowey@darcs.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Fri, Sep 18, 2009 at 16:16:29 +0100, Neil Mitchell wrote:<br>
> The underlying structure is that each command (mode in CmdArgs<br>
> terminology) takes a list of arguments drawn from a larger set of<br>
> arguments. You've optimised for parsing these options by keeping them<br>
> as an unstructured list. CmdArgs optimises for using these arguments<br>
> by having a real structure that can be properly queried. I would hope<br>
> that you replace your current options code with one using a proper<br>
> structure - since it will make your lives far easier.<br>
</div>...<br>
<div class="im">> The reason for all this effort is that you've flattened your flags,<br>
> which makes it harder to work with them, and guarantees you have<br>
> subtle bugs all over the place.<br>
<br>
</div>Yeah, the lists are definitely a source of potential bugginess.<br>
<br>
I wonder: what if we just replaced [DarcsFlag] with Set DarcsFlag.<br>
Would that not achieve the intended effect as well?<br></blockquote><div><br>I'm not certain, but I think a switch like this assumes that we have a systematic way to combine multiple flags. Something akin to a monoid instance. My understanding is that we initialize a [DarcsFlag] with some defaults and then toss in more elements as we go, from places like the command line. I bet we're not consistent about how we do the lookup and "tossing in" when we add new values to the list. If I'm wrong this may be easier than I'm thinking. I'm imagining that sometimes the later option is an override and sometime it behaves as a combination.<br>
<br>I do get your point about query efficiency though. And I think you're right that using Data.Set would provide good enough lookup performance. Well, okay, I've never seen our queries of [DarcsFlag] show up in the profiling data so I don't really feel like it's something that is worth optimizing.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Largely irrelevant digression<br>
-----------------------------<br>
[Folding: search for "Back to Darcs"]<br>
<br>
It doesn't matter to me very much whether we use a record or some sort<br>
of list/set; I was mostly curious. If I may drop into random<br>
chattiness, in a program called GenI, I also use a list of flags<br>
approach (learning from Darcs).<br>
<br>
There are three advantages for me.<br>
<br>
1. I can have people write GenI-like applications using the GenI<br>
library that have a subset of my flags and that add their own.<br>
<br>
2. I can then group by flags into thematic sections like "Core options",<br>
"Input files", and "Optimisations". When I type geni --help, I<br>
automatically get the output broken down into sections with some<br>
flags appearing in more than one section (for example in both 'core<br>
options' and 'input files'). Darcs actually also does this to an<br>
extent with its 'Basic' vs 'Advanced' options.<br>
<br>
GenI only has one Mode in CmdArgs terms, but it's a big one!<br>
<br>
3. Because I did not want to write getter/setter type functions like<br>
[snip]<br>
Also another disadvantage is that every time I look at this code, I get<br>
the feeling of really going about things in the most complicated<br>
Rube Goldbergesque way I could :-(<br></blockquote><div><br>Interesting approach. Has anyone looked at the cabal-install source to see how they tackle this problem? I recall a conversation once where Duncan was telling me he's reasonably happy with the way resolving of defaults vs. command line options works in cabal-install. So maybe they have something worth stealing ideas from? <br>
<br>Hopefully I'm not off in left field here. I haven't really been following the discussion, so if my comments don't seem to make sense, then they probably don't :)<br><br>Jason<br></div></div>