darcs

Patch 1289 purify Darcs.UI.Defaults, fixing two problems on the way

Title purify Darcs.UI.Defaults, fixing two problems on the way
Superseder Nosy List bfrk, gh
Related Issues
Status accepted Assigned To
Milestone 2.10.0

Created on 2015-02-19.22:31:18 by bfrk, last changed 2015-07-01.22:14:23 by gh.

Files
File name Status Uploaded Type Edit Remove
beautified-error-messages-for-command-line-and-default-files.dpatch bfrk, 2015-03-10.12:19:09 application/x-darcs-patch
patch-preview.txt bfrk, 2015-02-19.22:31:18 text/x-darcs-patch
patch-preview.txt bfrk, 2015-02-22.22:25:01 text/x-darcs-patch
patch-preview.txt bfrk, 2015-03-10.12:19:09 text/x-darcs-patch
purify-darcs_ui_defaults_-fixing-two-problems-on-the-way.dpatch dead bfrk, 2015-02-19.22:31:18 application/x-darcs-patch
purify-darcs_ui_defaults_-fixing-two-problems-on-the-way.dpatch dead bfrk, 2015-02-22.22:25:01 application/x-darcs-patch
unnamed bfrk, 2015-02-19.22:31:18
unnamed bfrk, 2015-02-22.22:25:01
unnamed bfrk, 2015-03-10.12:19:09
See mailing list archives for discussion on individual patches.
Messages
msg18171 (view) Author: bfrk Date: 2015-02-19.22:31:18
1 patch for repository http://darcs.net/screened:

patch 798d796394cbcf0e3aded817eea188363558818f
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Thu Feb 19 23:17:03 CET 2015
  * purify Darcs.UI.Defaults, fixing two problems on the way
  
  The IO that was in Darcs.UI.Defaults has been moved to the caller
  (Darcs.UI.RunCommand.runCommand). This allows us to fix a regression:
  relative paths given as option arguments in defaults files were not resolved
  with respect to the same working directory as when giving the option on the
  command line. The ordering constraints of commandPrereq vs.
  getGlobal/getPreflist are now concentrated in one place and documented.
  
  Some changes related to errors and how to report them are also included in
  this patch since it would have been difficult to record them separately:
  
  - applyDefaults no longer stops on the first error, instead accumulates all
    errors and returns them together with the result in a pair. This makes it
    easy to postpone the actual failure to a point after the standard command
    actions (--help, --list-options, --disable) have been handled. Which in
    turn fixes a problem with the generalized contrib/_darcs.zsh.
  
  - replacing use of unlines with (intercalate "\n") when concatenating error
    messages avoids many uses of the ugly chompTrailingNewline
Attachments
msg18211 (view) Author: bfrk Date: 2015-02-22.16:23:56
If fear this patch has a severe bug. Please ignore for the moment, will
send an amended version.
msg18215 (view) Author: bfrk Date: 2015-02-22.22:25:01
This bundle obsoletes the earlier one. Here is an example for the integrated
error messages:

> darcs record -i -a --bla
command line: unrecognized option `--bla'
command line: conflicting options: interactive, all/no-interactive

This what you get if you add a line

  ALL --bad

to your defaults file:

> darcs record -i -a --bla
command line: unrecognized option `--bla'
command line: conflicting options: interactive, all/no-interactive
user defaults: command 'record' has no option 'bad'.


3 patches for repository http://darcs.net/screened:

patch fbf4af538131009e0929b6b6429d154706b97fd5
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Feb 22 22:14:01 CET 2015
  * purify Darcs.UI.Defaults, fixing two problems on the way
  
  The IO that was in Darcs.UI.Defaults has been moved to the caller
  (Darcs.UI.RunCommand.runCommand). This allows us to fix a regression:
  relative paths given as option arguments in defaults files were not resolved
  with respect to the same working directory as when giving the option on the
  command line. The ordering constraints of commandPrereq vs.
  getGlobal/getPreflist are now concentrated in one place and documented.
  
  Some changes related to errors and how to report them are also included in
  this patch since it would have been difficult to record them separately:
  
  - applyDefaults no longer stops on the first error, instead accumulates all
    errors and returns them together with the result in a pair. This makes it
    easy to postpone the actual failure to a point after the standard command
    actions (--help, --list-options, --disable) have been handled. Which in
    turn fixes a problem with the generalized contrib/_darcs.zsh.
  
  - replacing use of unlines with (intercalate "\n") when concatenating error
    messages avoids many uses of the ugly chompTrailingNewline
  
  - error messages returned by getOpt and those generated by applyDefaults are
    now in the same format

patch 017b7bcc7ee5dba59e858aa61cabffe66870b7e1
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Feb 22 19:30:26 CET 2015
  * added giveup to Darcs.Util.Exception as a replacement for fail
  
  It is commonly agreed upon that fail is an ugly wart in the Monad class and
  should not be used for serious programs. Its only sensible justification is
  to support de-sugaring of do blocks with failing pattern matches.

patch bec40a8e29ef0795ec64696ad142b3a691276eba
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Feb 22 22:15:10 CET 2015
  * use giveup instead of fail in Darcs.UI.RunCommand
Attachments
msg18236 (view) Author: bfrk Date: 2015-02-27.02:48:50
I am a bit hesitant to screen this yet because I already had to make a
number of changes between the first version and the current (hopefully
last) one. On the other hand I would really like this to go into 2.10,
not least because it fixes two (admittedly minor) bugs.

I know you guys are busy, but could someone take a look at this? I just
want some assurance that what I did here isn't complete nonsense.
msg18285 (view) Author: bfrk Date: 2015-03-10.12:19:09
Final update for this patch bundle. Changed w.r.t. the previous version:

* add a small patch to rectify spelling of messages from
Darcs.UI.Defaults

* rename the replacement 'fail' from 'giveup' to 'die' (like in Perl).

I am going to screen this now.

5 patches for repository http://darcs.net/screened:

patch e1ed3b126134983f223ae0907dad11e2d1dcb3da
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Fri Feb 13 03:17:12 CET 2015
  * beautified error messages for command line and default files

patch fbf4af538131009e0929b6b6429d154706b97fd5
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Feb 22 22:14:01 CET 2015
  * purify Darcs.UI.Defaults, fixing two problems on the way
  
  The IO that was in Darcs.UI.Defaults has been moved to the caller
  (Darcs.UI.RunCommand.runCommand). This allows us to fix a regression:
  relative paths given as option arguments in defaults files were not resolved
  with respect to the same working directory as when giving the option on the
  command line. The ordering constraints of commandPrereq vs.
  getGlobal/getPreflist are now concentrated in one place and documented.
  
  Some changes related to errors and how to report them are also included in
  this patch since it would have been difficult to record them separately:
  
  - applyDefaults no longer stops on the first error, instead accumulates all
    errors and returns them together with the result in a pair. This makes it
    easy to postpone the actual failure to a point after the standard command
    actions (--help, --list-options, --disable) have been handled. Which in
    turn fixes a problem with the generalized contrib/_darcs.zsh.
  
  - replacing use of unlines with (intercalate "\n") when concatenating error
    messages avoids many uses of the ugly chompTrailingNewline
  
  - error messages returned by getOpt and those generated by applyDefaults are
    now in the same format

patch 71da2492bd3a0cb5bd35679be9bb99343368a161
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sat Mar  7 13:25:46 CET 2015
  * Darcs.UI.Defaults: upper case initial letter in error messages
  
  This brings it in line with how messages in Darcs are formatted elsewhere.

patch c4a5824efdb07c49ddb9dc2c828bd59031702626
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Tue Mar 10 12:54:23 CET 2015
  * added die action to Darcs.Util.Exception as a replacement for fail
  
  It is commonly agreed upon that fail is an ugly wart in the Monad class and
  should not be used for serious programs. Its only sensible justification is
  to support de-sugaring of do blocks with failing pattern matches.

patch e90c41bea6050fd35d7a56ad7a8c702bfd5bb80c
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Tue Mar 10 12:58:16 CET 2015
  * use die instead of fail in Darcs.UI.RunCommand
Attachments
msg18288 (view) Author: bfrk Date: 2015-03-10.12:36:44
Setting the milestone to 2.10 for the reasons given below.
msg18433 (view) Author: ganesh Date: 2015-06-09.17:52:13
I've looked at the purify Darcs.UI.Defaults patch and it makes sense to 
me, though I didn't understand every detail.

I'm not so sure about replacing 'fail': while having 'fail' in the Monad 
class along with the implicit desugaring of pattern-match failure is 
definitely bad, having a standard method for failure is useful. I'm not 
sure if the replacement implementation complicates error catching, e.g. 
when using darcs as a library. It's probably ok as calling exit does 
throw an ExitException so it is still possible.

Anyway, it seems like there are plans afoot to move 'fail' out to its 
own class, so it probably doesn't hurt to be isolated from it for the 
time being.

Sorry I didn't manage to look at this any sooner. I guess it still may 
make sense for 2.10 - Guillaume can decide on that.
msg18655 (view) Author: gh Date: 2015-07-01.22:07:50
I'm pushing the following into 2.10.1:

* beautified error messages for command line and default files
* purify Darcs.UI.Defaults, fixing two problems on the way
* added debugDocLn to Darcs.Util.Printer
* errorDoc now prints a stack trace (if profiling was enabled)
* Darcs.UI.Defaults: upper case initial letter in error messages


i.e. everything except the "fail-replacement".
msg18656 (view) Author: gh Date: 2015-07-01.22:14:23
Also pushing "adapted tests/disable.sh to improved help completion" ,
to fix disable.sh test failure because of the "purify
Darcs.UI.Defaults" patch.
History
Date User Action Args
2015-02-19 22:31:18bfrkcreate
2015-02-22 16:23:57bfrksetmessages: + msg18211
2015-02-22 22:25:02bfrksetfiles: + patch-preview.txt, purify-darcs_ui_defaults_-fixing-two-problems-on-the-way.dpatch, unnamed
messages: + msg18215
2015-02-27 02:48:51bfrksetmessages: + msg18236
2015-03-10 12:19:10bfrksetfiles: + patch-preview.txt, beautified-error-messages-for-command-line-and-default-files.dpatch, unnamed
messages: + msg18285
2015-03-10 12:21:19bfrksetstatus: needs-screening -> needs-review
2015-03-10 12:36:44bfrksetmessages: + msg18288
milestone: 2.10.0
2015-06-09 17:52:13ganeshsetstatus: needs-review -> accepted-pending-tests
nosy: + gh
messages: + msg18433
2015-06-10 05:21:55ganeshsetstatus: accepted-pending-tests -> accepted
2015-07-01 22:07:50ghsetmessages: + msg18655
2015-07-01 22:14:23ghsetmessages: + msg18656