Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspection on field order in Semigroup instances #387

Open
chshersh opened this issue Aug 25, 2020 · 0 comments
Open

Inspection on field order in Semigroup instances #387

chshersh opened this issue Aug 25, 2020 · 0 comments
Labels

Comments

@chshersh
Copy link
Contributor

Consider the following code:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant