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 return -> pure as default hint, active phase of proposal 0314 #1315

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Anton-Latukha
Copy link
Contributor

@Anton-Latukha Anton-Latukha commented Nov 13, 2021

GHC 9.2 enabled by default warn on this.

Upstream is: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0314-warn-noncanonical-monad-instance-by-default.rst

Enabling suggestion by default also allows at once to consolidate return & pure rewriting rules.

Consolidation diff is seen through 48696e2.

Seems because of that (or because rule was warn in future & now hint by default) - now chains of rules changed, so now cabal v2-run -- hlint --test not passes & idk what to do here.

Also cabal v2-run hlint -- --generate-summary seems to use some old cache for generation of hints.md. Reported into #1316.

This is a simple massive rename, so the next commit diff deduplication would be understandable.
Because hlint now advices return -> pure by default, return rules got converted into pure
rules in the previous commit, this commit deletes rules fould to be duplicates.
Seems like cabal v2-run hlint -- --generate-summary has state preservation
issues. Maybe it does not work without `cabal v2-run -- hlint --test` run beforehead.

I changed `name` & `note` fields several times & was regenerating `hints.md` -
but they were not updating with new information.

Like now - I deleted a bunch of rules - it did not regenerated `hints.md`
@Anton-Latukha Anton-Latukha changed the title add return -> pure as default a hint, active phase of proposal 0314 add return -> pure as default hint, active phase of proposal 0314 Nov 13, 2021
@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Nov 14, 2021

If I would not reach my hands & mind to debug all what is going on before review - would say thanks to concise information/comments on project operation & what needs to be done to merge properly.

@ndmitchell
Copy link
Owner

Sorry for the delay in response, I've been a bit ill over the last bit of time.

My understanding is the proposal mentioned warns about definitions in instances, whereas the patch here moves uses. Is that right?

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Jan 4, 2022

My understanding is the proposal mentioned warns about definitions in instances, whereas the patch here moves uses. Is that right?

Yes. Correct understanding.


The PR has two actions:

  1. The return -> pure rule. Currently submitting it as a hint.
  2. The rule graph gets adjusted.

I think I should reopen the PR. I hit a Cabal bug during the initial stage, & wanted to do everything needed in 1 PR, with is probably too much of a leap/review in 1 PR, and now I have a better way to form the message. Seing there are 3 distinct phases to this.

@Anton-Latukha Anton-Latukha marked this pull request as draft January 4, 2022 12:33
@ndmitchell
Copy link
Owner

I think the intent is pretty clear, so happy to discuss this in terms of words, without adjusting the code.

The proposal you link to doesn't mention suggesting people use pure instead of return. Is there community agreement that is the end state?

@andreasabel
Copy link

Is there community agreement that is the end state?

Na, I won't think so. I prefer return over pure at the end of monadic functions as it is more suggestive there, and in line with other programming languages (such as Java).

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.

3 participants