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

Chore: formatting, explicit imports. #5847

Merged
merged 2 commits into from Mar 20, 2024
Merged

Conversation

Unisay
Copy link
Contributor

@Unisay Unisay commented Mar 20, 2024

Housekeeping chore: format a few modules (Purity) before changing them.

@Unisay Unisay requested a review from michaelpj March 20, 2024 09:50
@Unisay Unisay self-assigned this Mar 20, 2024
@Unisay Unisay force-pushed the yura/term-eval-order-builtin-arity branch from 2092385 to 17c0a19 Compare March 20, 2024 09:55
Copy link
Contributor

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unhappy with ad-hoc decisions here.

import Data.DList qualified as DList
import Data.List.NonEmpty qualified as NE
import PlutusCore.Builtin (BuiltinMeaning (..), ToBuiltinMeaning (..), TypeScheme (..))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we reached any agreement on whether this is desirable or not. For me, this makes things worse, since these are project modules that I would expect people to be familiar with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are project modules that I would expect people to be familiar with.

Actually, in my case it is other way around: I might be acquainted with the Prettyprinter symbols from using the library in other projects, but I don't yet know all the symbols exported by our PlutusTx modules. 🤷🏼‍♂️

Anyway, I am not particularly hang up on explicit imports, I can undo those ones you prefer to leave wildcard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a policy. So I'm not saying don't do it - we don't have a policy so we simply have various preferences, and yours are just as valid.

But I would much prefer to have a policy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should have a policy. I personally prefer explicit export lists, and I think this can be enforced somewhere either in the formatter (once we decide what we want) or in the commit pipeline. Maybe we should talk about this during the technical discussion?

-- or we don't know what comes next.
data EvalTerm tyname name uni fun a =
Unknown
{- | Either the "next" term to be evaluated, along with its 'Purity' and 'WorkFreedom',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more this happens the more I dislike our current approach of "people can just reformat things to their personal preference". It's terrible. Please can we decide to either use fourmolu consistently or just not reformat things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment nothing stops someone just reformatting this back a different way with "Chore: reformatting" :(

Copy link
Contributor Author

@Unisay Unisay Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few things here are decided to match my personal preference (e.g. explicit imports and some naming choices, etc.)

The majority of formatting decisions falls in one of 3 categories here:

  1. Developer's personal preference.
  2. A thing that is advised by the STYLEGUIDE (e.g. 2 spaces, not 4)
  3. A thing that is decided by a fourmolu and isn't configurable.
  4. A thing that is decided by a shared project-specific fourmolu configuration.

My goal is to have most of the things fall into 1 or 3.

I am willing to undo the changes you think are 0 or 2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For plutus, my formatter is set to stylish-haskell and it seems to format new code in the same way the existing code in the module is formatted (which can be different from module to module). I have no idea how that happens. I use VSCode if that makes any difference.

Anyway, I agree that it's weird that formatting keeps changing on a module to module basis. @michaelpj did the team try to use fourmolu at some point? What didn't they like about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stylish-haskell and it seems to format new code in the same way the existing code in the module is formatted

Two reasons:

  • we already enforce stylish-haskell (git hooks) .
  • stylish-haskell is very liberal: it does change the imports and aligns vertical arrows, equals, etc. It won't change indentation.

By the way, I have configured local formatting such that fourmolu -produced output is piped to the stylish-haskell: their combination leads to a least change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thing that is decided by a fourmolu

Nothing in our style guide or contributing guide even says that we use fourmolu at all.

By the way, I have configured local formatting such that fourmolu -produced output is piped to the stylish-haskell: their combination leads to a least change.

😱

did the team try to use fourmolu at some point? What didn't they like about it?

@effectfully is the main opponent, you can search in slack for some discussion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ana-pantilie see this for example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #5761 (review) for example.

I initially read the first diff as fourmolu removing the INLINEABLE pragmas which got me very scared, but I see it's only adding a newline between the pragma and the type declaration, right? I looked up the docs and INLINEABLE or INLINE can be added anywhere in the module I believe, https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/pragmas.html#inlinable-pragma.
The other changes you pointed out aren't really dangerous, are they? If they're not, although I agree that they're ugly, I think they're not that bad once you consider the bigger picture. Don't hate me, but I think that as long as these "formatting bugs" are cosmetic and relatively infrequent it's a small price to pay for having consistent automated formatting.

@Unisay
Copy link
Contributor Author

Unisay commented Mar 20, 2024

I am unhappy with ad-hoc decisions here.

Let me undo those decisions that make you unhappy. What is it in particular?

@michaelpj
Copy link
Contributor

"unhappy" was meant to attach to "ad-hoc" rather than the specific decisions :) I just think it's past time we agreed on a policy.

@Unisay Unisay added the No Changelog Required Add this to skip the Changelog Check label Mar 20, 2024
@Unisay Unisay merged commit 53e45af into master Mar 20, 2024
5 of 6 checks passed
@Unisay Unisay deleted the yura/term-eval-order-builtin-arity branch March 20, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants