Commit 3967b6d
committed
Fix: don't suggest "Use :" when OverloadedLists is enabled (fixes #1602)
With OverloadedLists, `\x -> [x]` and `(: [])` have different types:
the former produces any IsList instance (Vector a, Set a, NonEmpty a,
...) while the latter specialises to [a]. Applying the suggestion
produces code that no longer type-checks.
Move the hint from data/hlint.yaml into a code-based hint in
Hint/List.hs, gated on `not overloadedListsOn` (same pattern as #114
for "Use list literal" and #1674 for "Use unwords").
The hint still fires for `\x -> [x]` when the module does not enable
OverloadedLists, and is suppressed per-file when it does.
Tests added to the TEST block in Hint/List.hs. Self-test: 966 tests,
all pass.1 parent 086bf44 commit 3967b6d
2 files changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| 194 | + | |
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
266 | 284 | | |
267 | 285 | | |
268 | 286 | | |
| |||
0 commit comments