Skip to content

Commit 035a4bb

Browse files
committed
Add OverloadedLists caveat note to "Use :" hint (fixes #1602)
With OverloadedLists enabled, `\x -> [x]` and `(: [])` may have different types: the former can produce any IsList instance (Vector, Set, NonEmpty, ...) while the latter specialises to [a]. Applying the suggestion then produces code that no longer type-checks. Per the maintainer's response on #1602, auto-suppression is not warranted (OverloadedLists is uncommon), but an explanatory note is.
1 parent 086bf44 commit 035a4bb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

data/hlint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
- hint: {lhs: any (const True) x, rhs: not (null x), name: Use null}
212212
- hint: {lhs: length x /= 0, rhs: not (null x), note: IncreasesLaziness, name: Use null}
213213
- hint: {lhs: 0 /= length x, rhs: not (null x), note: IncreasesLaziness, name: Use null}
214-
- hint: {lhs: "\\x -> [x]", rhs: "(:[])", name: "Use :"}
214+
- hint: {lhs: "\\x -> [x]", rhs: "(:[])", name: "Use :", note: "incorrect if OverloadedLists is enabled"}
215215
- hint: {lhs: map f (zip x y), rhs: zipWith (curry f) x y, side: not (isApp f)}
216216
- hint: {lhs: "map f (fromMaybe [] x)", rhs: "maybe [] (map f) x"}
217217
- hint: {lhs: "concatMap f (fromMaybe [] x)", rhs: "maybe [] (concatMap f) x"}

0 commit comments

Comments
 (0)