darcs

Patch 1466 cleanup in Darcs.Patch.Merge: use case instead of from...

Title cleanup in Darcs.Patch.Merge: use case instead of from...
Superseder Nosy List bfrk
Related Issues
Status accepted Assigned To
Milestone

Created on 2016-03-08.23:20:40 by bfrk, last changed 2016-03-18.19:58:03 by gh.

Files
File name Status Uploaded Type Edit Remove
cleanup-in-darcs_patch_merge_-use-case-instead-of-fromjust-_do-return-____.dpatch bfrk, 2016-03-08.23:20:39 application/x-darcs-patch
patch-preview.txt bfrk, 2016-03-08.23:20:39 text/x-darcs-patch
unnamed bfrk, 2016-03-08.23:20:39 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg19057 (view) Author: bfrk Date: 2016-03-08.23:20:39
Note that these are pure, total functions. There is no justification for
using 'fromJust' here, merely to support monadic style.

(If the latter is preferred, then the proper choice would be
Data.Functor.Identity.runIdentity which is total and has guaranteed zero
runtime overhead.)

Anyway, cascading case expressions are clearer IMO, less noisy (e.g. no
"return $" on each line), and are generally more robust against changes in
the data type (you get a warning about incomplete patterns if constructors
are added (though I concede that this is unlikely here)).

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

patch c553aac0b42564699190b34cc54a245e7e3c4e9e
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Tue Mar  8 23:49:03 CET 2016
  * cleanup in Darcs.Patch.Merge: use case instead of fromJust (do return ...)
Attachments
msg19081 (view) Author: bfrk Date: 2016-03-14.00:11:20
I accidentally pushed this to reviewed (instead of screened) but
obliterated immediately afterwards. Sorry!
msg19104 (view) Author: gh Date: 2016-03-18.19:58:03
I remember I tried to get rid of such use of "fromJust / return $"
elsewhere in Darcs but got caught by a "my brain just exploded" GHC
error, also I was unsure of the improvement on readability of the code.

In the present case I see that it *is* an improvement.

Accepted.
History
Date User Action Args
2016-03-08 23:20:40bfrkcreate
2016-03-14 00:11:20bfrksetstatus: needs-screening -> needs-review
messages: + msg19081
2016-03-18 19:58:03ghsetstatus: needs-review -> accepted
messages: + msg19104