From b7bf780c52a74c11a0b005e64ed788b9b6f81ea6 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Fri, 27 Aug 2021 22:11:41 +1000 Subject: [PATCH] dev: hlint: Avoid use of reverse. Note that this is semantically different, and will produce different results. In particular, the sort is now stable, i.e. account names with the same balance will not have their order reversed relative to each other. In this context there doesn't seem to be a reason to prefer one order to the other, so I'm making this change. --- .hlint.yaml | 1 - bin/_hledger-chart.hs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 5e6ed11ec..9205d4fb1 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -10,7 +10,6 @@ - ignore: {name: "Move brackets to avoid $"} - ignore: {name: "Redundant $"} - ignore: {name: "Redundant bracket"} -- ignore: {name: "Avoid reverse"} - ignore: {name: "Use sortOn"} - ignore: {name: "Use camelCase"} - ignore: {name: "Use list comprehension"} diff --git a/bin/_hledger-chart.hs b/bin/_hledger-chart.hs index e4af1d8b3..36a187be4 100755 --- a/bin/_hledger-chart.hs +++ b/bin/_hledger-chart.hs @@ -147,7 +147,7 @@ genPie opts (items, _total) = def { _pie_background = solidFillStyle $ opaque $ (samesignitems, sign) = sameSignNonZero items top n t = topn ++ [other] where - (topn,rest) = splitAt n $ reverse $ sortBy (comparing snd) t + (topn,rest) = splitAt n $ sortBy (flip $ comparing snd) t other = ("other", sum $ map snd rest) num = chart_items_ opts hue = if sign > 0 then red else green where (red, green) = (0, 110)