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

Support hpack by running hpack before ormolu #10

Open
codygman opened this issue Oct 5, 2022 · 4 comments
Open

Support hpack by running hpack before ormolu #10

codygman opened this issue Oct 5, 2022 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@codygman
Copy link

codygman commented Oct 5, 2022

Otherwise the cabal files aren't there.

@cdepillabout cdepillabout added good first issue Good for newcomers help wanted Extra attention is needed labels Oct 5, 2022
@cdepillabout
Copy link
Collaborator

cdepillabout commented Oct 5, 2022

That doesn't sound too unreasonable.

Some reservations I would have are:

  1. I guess you'd need some logic to recurse over the repo and run hpack on any package.yaml files you find. I'm not sure what sort of problems you'd encounter with this, but it'd be really nice to have some tests that this is actually working as promised.
  2. I think committing .cabal files is now seen as good practice: https://www.fpcomplete.com/blog/storing-generated-cabal-files/. This feature wouldn't be necessary if you committed cabal files.
  3. In theory it would be more helpful if you had a separate action for recursively running hpack. That way, you could pair that hpack-action with either this repo or the ormolu GitHub Action. Or any other Haskell-related GitHub Action that requires .cabal files to be present.

@wraithm
Copy link
Collaborator

wraithm commented Oct 5, 2022

IMHO, this is an upstream problem. Fourmolu should just support hpack/package.yaml. It could even run hpack in memory and then use the exact cabal file logic.

@cdepillabout
Copy link
Collaborator

Oh, also, this fourmolu-action should currently be working even if you don't check-in the .cabal files.

In our repo at work, we don't check in .cabal files and this action still works for us. fourmolu will still output a line like:

Could not find a .cabal file for /home/runner/work/our-org/our-repo/package-foo/src/FooBar.hs

But fourmolu still runs on this file and correctly checks the formatting, although it is not able to figure out default language extensions or fixities for dependencies' operators: https://github.com/fourmolu/fourmolu#language-extensions-dependencies-and-fixities

@brandonchinn178
Copy link
Member

IMHO, this is an upstream problem. Fourmolu should just support hpack/package.yaml. It could even run hpack in memory and then use the exact cabal file logic.

I don't think Fourmolu (or Ormolu) should be responsible for generating cabal files. If you're using stack, why not run a short stack path (or some other trivial stack command to run hpack) before running the action? It seems like a lot of overhead for Fourmolu (e.g. adding hpack as a dependency) when there's such a simple workaround before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants