[darcs-users] darcs patch: Refactor logic flow in `main`.

Trent W. Buck trentbuck at gmail.com
Thu Jan 15 10:28:42 UTC 2009


On Thu, Jan 15, 2009 at 09:37:55AM +0000, Eric Kow wrote:
> On Thu, Jan 15, 2009 at 20:16:53 +1100, Trent W.Buck wrote:
> > Sending this one separately because it's relatively long.
> > 
> > Thu Jan 15 14:45:12 EST 2009  Trent W. Buck <trentbuck at gmail.com>
> >   * Refactor logic flow in `main`.
>  
> Applied, thanks!  This gives an appreciable improvement to code clarity.
> 
> Lest my recent review to another bundle send the wrong message, I really
> *do* such refactors and 'minor' patches (they add up).  I just wanted to
> throw in an 'in case of doubt' and also to point out that some
> situations deserve more doubt.
> 
> Refactor logic flow in `main`.
> ------------------------------
> > Trent W. Buck <trentbuck at gmail.com>**20090115034512
> >  Ignore-this: 182db125fbd030cb3f8b442ef1822155
> > ] hunk ./src/darcs.hs 55
> >  main = with_atexit $ withSignalsHandled $
> > +  argv <- getArgs
> >    when (length argv < 1) $
> >         do print_version
> ...
> 
> > +  when (length argv == 1) $ do
> > +       let argv0 = head argv
> 
> Since we have all that fancy pattern matching, we might be better
> off just using a case statement on argv to avoid the use of head.

Good idea.  I think the problem I've been having today is that I'm
trying to make the code more readable, but at the same time avoid just
rewriting the function completely.  At least, that's my excuse for not
thinking of case :-)


More information about the darcs-users mailing list