From 81ceea8d99a57e86471c8436465c0b85f1db9397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Voigtl=C3=A4nder?= Date: Sun, 4 Feb 2024 22:44:23 +0100 Subject: [PATCH 1/2] avoiding repeated work on lists to be "cycled" --- data/hlint.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/hlint.yaml b/data/hlint.yaml index 92bd357c..26db5c99 100644 --- a/data/hlint.yaml +++ b/data/hlint.yaml @@ -158,6 +158,11 @@ - warn: {lhs: concatMap f (repeat x), rhs: cycle (f x)} - warn: {lhs: concat (repeat x), rhs: cycle x} - warn: {lhs: "cycle [x]", rhs: repeat x} + - hint: {lhs: filter f (cycle x), rhs: cycle (filter f x)} + - hint: {lhs: mapMaybe f (cycle x), rhs: cycle (mapMaybe f x)} + - hint: {lhs: catMaybes (cycle x), rhs: cycle (catMaybes x)} + - hint: {lhs: lefts (cycle x), rhs: cycle (lefts x)} + - hint: {lhs: rights (cycle x), rhs: cycle (rights x)} - warn: {lhs: head (reverse x), rhs: last x} - warn: {lhs: last (reverse x), rhs: head x, note: IncreasesLaziness} - warn: {lhs: head (drop n x), rhs: x !! n, side: isNat n} From 8e12b4ac4867c4ac9128b6af97deb2f83f5c90d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Voigtl=C3=A4nder?= Date: Sun, 4 Feb 2024 23:01:07 +0100 Subject: [PATCH 2/2] name the hints --- data/hlint.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/hlint.yaml b/data/hlint.yaml index 26db5c99..5dac927d 100644 --- a/data/hlint.yaml +++ b/data/hlint.yaml @@ -158,11 +158,11 @@ - warn: {lhs: concatMap f (repeat x), rhs: cycle (f x)} - warn: {lhs: concat (repeat x), rhs: cycle x} - warn: {lhs: "cycle [x]", rhs: repeat x} - - hint: {lhs: filter f (cycle x), rhs: cycle (filter f x)} - - hint: {lhs: mapMaybe f (cycle x), rhs: cycle (mapMaybe f x)} - - hint: {lhs: catMaybes (cycle x), rhs: cycle (catMaybes x)} - - hint: {lhs: lefts (cycle x), rhs: cycle (lefts x)} - - hint: {lhs: rights (cycle x), rhs: cycle (rights x)} + - hint: {lhs: filter f (cycle x), rhs: cycle (filter f x), name: Move cycle out} + - hint: {lhs: mapMaybe f (cycle x), rhs: cycle (mapMaybe f x), name: Move cycle out} + - hint: {lhs: catMaybes (cycle x), rhs: cycle (catMaybes x), name: Move cycle out} + - hint: {lhs: lefts (cycle x), rhs: cycle (lefts x), name: Move cycle out} + - hint: {lhs: rights (cycle x), rhs: cycle (rights x), name: Move cycle out} - warn: {lhs: head (reverse x), rhs: last x} - warn: {lhs: last (reverse x), rhs: head x, note: IncreasesLaziness} - warn: {lhs: head (drop n x), rhs: x !! n, side: isNat n}