Partial review:
On 11/02/2020 08:13, Ben Franksen wrote:
> * diff command: make construction of trees more obviously correct
Fine
> * diff command: simplify display of the log
Fine (the old code does indeed seem quite convoluted)
> Sealed all <- return $ case (secondMatch matchFlags, patchset) of
> (True, _) -> seal patchset
> (False, s) -> seal $ patchSetSnoc s unrecorded'
>
> Sealed ctx <- return $ if firstMatch matchFlags
> then matchFirstPatchset matchFlags patchset
> else seal patchset
>
> Sealed match <- return $ if secondMatch matchFlags
> then matchSecondPatchset matchFlags patchset
> else seal all
>
> Sealed logmatch <- return $ if secondMatch matchFlags
> then seal match
> else seal patchset
The different ifs for secondMatch matchFlags feel a bit convoluted. It
looks like it could be reduced to something like this (or the equivalent
post the Maybe refactoring below)
(Sealed all, Sealed match, Sealed logmatch) <-
if secondMatch matchFlags
then let match = matchSecondPatchSet matchFlags patchset
in (seal patchset, seal match, seal match)
else let all = patchSetSnoc patchset unrecorded'
in (seal all, seal all, seal patchset)
Anyway, just a comment, I might send a followup myself.
> patch 428804718ada72c4dd91cc217586134cfb248798
> Author: Ben Franksen <ben.franksen@online.de>
> Date: Wed Jan 29 10:35:19 CET 2020
> * refactor matchFirst/SecondPatchset
>
> These functions now return a Maybe instead of being partial functions. This
> simplifies the call sites and avoids duplicated checks.
Can firstMatch and secondMatch be rewritten as isJust .
matchFirstPatchSet etc? I think they can, so we should. If not this
refactoring may be unsound :-)
|