darcs

Patch 734 Refactor: Extract function for handling extra arguments

Title Refactor: Extract function for handling extra arguments
Superseder Nosy List mndrix, stulli
Related Issues
Status accepted Assigned To
Milestone

Created on 2012-02-29.18:41:07 by stulli, last changed 2012-03-14.15:35:25 by gh.

Files
File name Status Uploaded Type Edit Remove
patch-preview.txt stulli, 2012-02-29.18:41:07 text/x-darcs-patch
patch-preview.txt stulli, 2012-02-29.22:12:56 text/x-darcs-patch
refactor_-extract-function-for-handling-extra-arguments.dpatch dead stulli, 2012-02-29.18:41:07 application/x-darcs-patch
refactor_-extract-function-for-handling-extra-arguments.dpatch stulli, 2012-02-29.22:12:56 application/x-darcs-patch
unnamed stulli, 2012-02-29.18:41:07
unnamed owst, 2012-02-29.20:16:45 text/html
unnamed stulli, 2012-02-29.22:12:56
See mailing list archives for discussion on individual patches.
Messages
msg15192 (view) Author: stulli Date: 2012-02-29.18:41:07
I also added some comments to make it easier to understand for
newcomers like me.

1 patch for repository http://darcs.net/screened:

Wed Feb 29 19:19:44 CET 2012  Andreas Brandt <andreas.brandt.de@googlemail.com>
  * Refactor: Extract function for handling extra arguments
Attachments
msg15193 (view) Author: owst Date: 2012-02-29.20:16:45
On 29 February 2012 18:41, Andreas Brandt <bugs@darcs.net> wrote:

>
> New submission from Andreas Brandt <andreas.brandt.de@googlemail.com>:
>
> I also added some comments to make it easier to understand for
> newcomers like me.
>
> 1 patch for repository http://darcs.net/screened:
>
> Wed Feb 29 19:19:44 CET 2012  Andreas Brandt <
> andreas.brandt.de@googlemail.com>
>  * Refactor: Extract function for handling extra arguments
>

Hi Andreas,

Thanks for the patch! A few comments (I've inlined parts of your patch):

> +    case extraArgumentsMatch extra cmd msuper of
> +        (True, _)    -> runWithHooks specops extra
> +        (False, msg) -> fail msg

I see that you're just throwing away the string in the True case. That
suggests
to me that you should use (Maybe String) as the return type, and that you
should run the command when there is Nothing as the error message. (Maybe
the
function should be called extraArgumentsError or something, to make sense of
the result type).

> +            nth_arg n       = nth_of n (commandExtraArgHelp cmd)
> +            nth_of 1 (h:_)  = h
> +            nth_of n (_:hs) = nth_of (n-1) hs
> +            nth_of _ []     = "UNDOCUMENTED"
> +

I notice this function was previously defined in the file, but it'd be good
to
use this opportunity to translate from underscore_identfiers to
camelCaseIdentifiers.

Cheers,
Owen.
Attachments
msg15194 (view) Author: stulli Date: 2012-02-29.22:12:56
Thanks for your suggestions!

I thought about using Maybe but noticed that Nothing would not
make sense for a succeeding match - i didn't think of renaming
the function though.

I amended the patch accordingly and hope i got the darcs send right.

1 patch for repository http://darcs.net/screened:

Wed Feb 29 22:30:51 CET 2012  Andreas Brandt <andreas.brandt.de@googlemail.com>
  * Refactor: Extract function for handling extra arguments
Attachments
msg15306 (view) Author: mndrix Date: 2012-03-13.22:07:58
Much easier to follow than the original code.  Thanks.

Dear committers, please push this patch.
History
Date User Action Args
2012-02-29 18:41:07stullicreate
2012-02-29 20:16:46owstsetfiles: + unnamed
messages: + msg15193
2012-02-29 22:12:56stullisetfiles: + patch-preview.txt, refactor_-extract-function-for-handling-extra-arguments.dpatch, unnamed
messages: + msg15194
2012-03-01 07:14:08ganeshsetstatus: needs-screening -> needs-review
2012-03-13 22:07:58mndrixsetstatus: needs-review -> accepted-pending-tests
nosy: + mndrix
messages: + msg15306
2012-03-14 15:35:25ghsetstatus: accepted-pending-tests -> accepted