ndmitchell / ndmitchell/hlint

Suggest breaking down conjunctions in list comprehensions

Open
#671 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
1.6k
Forks
210
PR merge metrics
No merged PRs in 30d

Description

I had an instance where I would have liked to see this:

    simpleCases :: (Int, Int) -> [Int]
    simpleCases (x, y) = [x | y >= x && p x]

being rewritten to this:

    simpleCases :: (Int, Int) -> [Int]
    simpleCases (x, y) = [x | y >= x, p x]

One way to probably achieve this in a special case like above (with just that one conjunction present) would have been:

    - hint: {lhs: "[x | y && z]", rhs: "[x | y, z]", name: Break down conjunction in list comprehension}

But Neil rightfully said (https://github.com/ndmitchell/hlint/pull/668#issuecomment-501168192) that this should also be made to work in cases like [x | a <- foo, b && c] etc., and that to that would require changes around https://github.com/ndmitchell/hlint/blob/master/src/Hint/List.hs#L58 in source.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/Hint/List.hs around line 58 and inspect how list-comprehension hints handle guards and qualifiers. Support conjunctions in guards alongside qualifiers such as [a <- foo, b && c], and verify that the suggested rewrite covers the examples in the issue without changing unrelated cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.