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

Add hlint rule, foldr (:) [] β†’ toList #451

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

ulidtko
Copy link
Contributor

@ulidtko ulidtko commented Oct 26, 2023

Hi @vrom911 πŸ‘‹ Long-time fan of Kowainik, here's a first contribution.

I was writing something with Relude, and had a sudden brainfart failing to remember how to say toList πŸ˜…
Instead I wrote foldr (:) [] β€” expecting Relude's HLint ruleset to remind me a less clumsy wording β€” but alas, it didn't say anything! That I was shocked, says something about the quality of kowainik stuff πŸ˜‰

Checklist

  • I've updated hlint.dhall accordingly to my changes (add new rules for the new imports, remove old ones, when they are outdated, etc.).
  • I've generated the new .hlint.yaml file (see this instructions).
  • I've updated the CHANGELOG with the short description of my latest changes.
    β€” πŸ€” Prolly not worth it?..

@ulidtko ulidtko requested a review from vrom911 as a code owner October 26, 2023 16:37
@ulidtko ulidtko changed the title Add a hlint rule Add hlint rule, foldr (:) [] β†’ toList Aug 29, 2024
@ulidtko ulidtko mentioned this pull request Aug 30, 2024
8 tasks
@tomjaguarpaw
Copy link
Contributor

This looks fine, but can we exclude the commit that does reformatting and quotes?

@tomjaguarpaw
Copy link
Contributor

I realize I don't understand the purpose of this HLint file. I thought it would be for linting relude itself, but it sounds like you are using it in your own projects. Is that right? Is that common practice?

@ulidtko
Copy link
Contributor Author

ulidtko commented Sep 2, 2024

This looks fine, but can we exclude the commit that does reformatting and quotes?

Sure. Rebased.

sounds like you are using it in your own projects. Is that right? Is that common practice?

Yep; it's common enough that I'd actually inherited a codebase where that's been done. When using relude, it makes sense to adopt its hlint rule file too β€” as it provides good guidance with all those "Use xyz from Relude" hints.

@ulidtko
Copy link
Contributor Author

ulidtko commented Sep 2, 2024

the commit that does reformatting and quotes

I should also note, the YAML version of the rule file is a generated output from Dhall source.

So those reformatting changes were a byproduct of following the documented process in README:

relude/README.md

Lines 764 to 791 in 49f415c

### Generating .hlint.yaml
Note, that we are using custom `hlint` setting which are `Relude` specific. To
keep it up to date don't forget to reflect your changes in this file. We are
using `Dhall` to maintain the configurations (lang version 22.0.0). To
use it follow the steps below.
First time:
```shell
$ cabal v2-install dhall-yaml-1.2.10
```
To generate `hlint` file:
```shell
$ dhall-to-yaml-ng <<< './hlint/hlint.dhall' > .hlint.yaml
```
Check that you have generated valid `.hlint.yaml` file without parse errors:
```shell
$ hlint test/Spec.hs
```
See our blog post where we describe the details of the implementation for this solution:
- [Dhall To HLint](https://kowainik.github.io/posts/2018-09-09-dhall-to-hlint)

They appear because of upstream fixes in Dhall, and relude's .hlint.yaml having not been regenerated from hlint/hlint.dhall for a while.

@tomjaguarpaw tomjaguarpaw merged commit c4f4a90 into kowainik:main Sep 2, 2024
12 checks passed
@tomjaguarpaw
Copy link
Contributor

I should also note, the YAML version of the rule file is a generated output from Dhall source.

So those reformatting changes were a byproduct of following the documented process in README:

Yes, understood. But it looks like either those instructions haven't been followed by others, or the version of dhall you're using is a later one, and it's doing something different. Currently I don't feel authorized to address that issue so I'd prefer we just do the simple, noise-free thing.

Thanks for this contribution!

@ulidtko ulidtko deleted the misc/add-hlint-rule branch September 2, 2024 08:39
@ulidtko
Copy link
Contributor Author

ulidtko commented Sep 2, 2024

or the version of dhall you're using is a later one

IIRC this was indeed the case... Anyhow, agree to keep it the simple way, thanks for merging πŸ™

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

Successfully merging this pull request may close these issues.

2 participants