kowainik / kowainik/stan

Inspection on field order in Semigroup instances

Open
#387 0 comments 1 reaction 0 assignees View on GitHub
inspection nice to have :nail_care:
Dominant language
Haskell
Stars
597
Forks
53
PR merge metrics
No merged PRs in 30d

Description

Consider the following code:

```haskell
data RowLen = RowLen
{ rowLenModule :: !Int
, rowLenLine :: !Int
, rowLenSev :: !Int
, rowLenMax :: !Int
, rowLenAvg :: !Int
}

instance Semigroup RowLen where
RowLen a1 b1 c1 d1 e1 <> RowLen a2 b2 c2 d2 e2 =
RowLen (max a1 a2) (max b1 b2) (max c1 c2) (max d1 d2) (max e1 e2)
```

This code involves some boilerplate and it's easy to introduce an error in there. We could implement an inspection that checks corresponding order of fileds on the leftt and right sides.

Contributor guide

Open the contributing guide

Research direction

No file, test, or analyzer entry point is named. Start with the Semigroup RowLen example and locate how existing inspections analyze instance bodies. Done means the analyzer detects mismatched corresponding field order in this pattern, with coverage for the example.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.