<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 1:14 PM, Eric Kow <span dir="ltr">&lt;<a href="mailto:kowey@darcs.net">kowey@darcs.net</a>&gt;</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>
&gt; The underlying structure is that each command (mode in CmdArgs<br>
&gt; terminology) takes a list of arguments drawn from a larger set of<br>
&gt; arguments. You&#39;ve optimised for parsing these options by keeping them<br>
&gt; as an unstructured list. CmdArgs optimises for using these arguments<br>
&gt; by having a real structure that can be properly queried.  I would hope<br>
&gt; that you replace your current options code with one using a proper<br>
&gt; structure - since it will make your lives far easier.<br>
</div>...<br>
<div class="im">&gt; The reason for all this effort is that you&#39;ve flattened your flags,<br>
&gt; which makes it harder to work with them, and guarantees you have<br>
&gt; 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&#39;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&#39;re not consistent about how we do the lookup and &quot;tossing in&quot; when we add new values to the list.  If I&#39;m wrong this may be easier than I&#39;m thinking.  I&#39;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&#39;re right that using Data.Set would provide good enough lookup performance.  Well, okay, I&#39;ve never seen our queries of [DarcsFlag] show up in the profiling data so I don&#39;t really feel like it&#39;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 &quot;Back to Darcs&quot;]<br>
<br>
It doesn&#39;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 &quot;Core options&quot;,<br>
   &quot;Input files&quot;, and &quot;Optimisations&quot;.  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 &#39;core<br>
   options&#39; and &#39;input files&#39;).  Darcs actually also does this to an<br>
   extent with its &#39;Basic&#39; vs &#39;Advanced&#39; options.<br>
<br>
   GenI only has one Mode in CmdArgs terms, but it&#39;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&#39;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&#39;m not off in left field here.  I haven&#39;t really been following the discussion, so if my comments don&#39;t seem to make sense, then they probably don&#39;t :)<br><br>Jason<br></div></div>