Skip to content

Commit 100de33

Browse files
committed
Avoid unnecessary zip since it walks the list twice and breaks fusion
1 parent 8702b19 commit 100de33

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

data/hlint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
- hint: {lhs: 0 /= length x, rhs: not (null x), note: IncreasesLaziness, name: Use null}
184184
- hint: {lhs: "\\x -> [x]", rhs: "(:[])", name: "Use :"}
185185
- hint: {lhs: map f (zip x y), rhs: zipWith (curry f) x y, side: not (isApp f)}
186+
- warn: {lhs: zip x (map f x), rhs: "map (\\y -> (y, f y)) x", note: IncreasesLaziness}
187+
- warn: {lhs: zip (map f x) x, rhs: "map (\\y -> (f y, y)) x", note: IncreasesLaziness}
188+
- warn: {lhs: zip x <$> traverse f x, rhs: "traverse (\\y -> (,) y <$> f y) x", note: IncreasesLaziness}
186189
- hint: {lhs: "map f (fromMaybe [] x)", rhs: "maybe [] (map f) x"}
187190
- warn: {lhs: not (elem x y), rhs: notElem x y}
188191
- hint: {lhs: foldr f z (map g x), rhs: foldr (f . g) z x, name: Fuse foldr/map}

0 commit comments

Comments
 (0)