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

HLS-bundled Fourmolu is outdated (< 0.12) #978

Open
georgefst opened this issue May 11, 2023 · 10 comments
Open

HLS-bundled Fourmolu is outdated (< 0.12) #978

georgefst opened this issue May 11, 2023 · 10 comments
Labels
Nix Nix- or nixpkgs-related

Comments

@georgefst
Copy link
Contributor

georgefst commented May 11, 2023

It was intended that #883 would cause Fourmolu 0.12 to be used as the dependency version for HLS' Fourmolu plugin. Unfortunately, this doesn't seem to have been the case. We bumped to a version of HLS which supports Fourmolu 0.12, and all else being equal, the latest version of a library should be picked up, so I'm not sure why this has happened.

We should force HLS to use Fourmolu 0.12, but I can't personally work out the right Haskell.Nix incantation to set the constraint.

To demonstrate that this is the case, notice that the HLS-bundled Fourmolu ignores single-constraint-parens, e.g. when formatting n = 1 :: Num a => a, so long as the HLS haskell.plugin.fourmolu.config.external isn't enabled.

@georgefst georgefst added the Nix Nix- or nixpkgs-related label May 11, 2023
@dhess
Copy link
Member

dhess commented May 11, 2023

Ugh. I don't understand how this happened.

@dhess
Copy link
Member

dhess commented May 11, 2023

We should force HLS to use Fourmolu 0.12, but I can't personally work out the right Haskell.Nix incantation to set the constraint.

What is the required Cabal incantation? I'll see about translating it to haskell.nix-speak.

@georgefst
Copy link
Contributor Author

What is the required Cabal incantation?

One way would be to run cabal configure --constraint='fourmolu>=0.12', from the root of the HLS repo.

@georgefst georgefst changed the title HLS-bundled Fourmolu is outdated (< 12) HLS-bundled Fourmolu is outdated (< 0.12) May 11, 2023
@dhess
Copy link
Member

dhess commented May 16, 2023

Hmm, I'm able to convince HLS (via haskell.nix) to use fourmolu-0.12.0.0, but when I do that, the dependency graph breaks on hlint, which is odd:

 nix develop -L                                                                                                                                                   ~/git/primer
warning: Git tree '/Users/dhess/git/primer' is dirty
trace: WARNING: license "LicenseRef-Apache" not found
haskell-project-plan-to-nix-pkgs> Cloning into '/private/tmp/nix-build-haskell-project-plan-to-nix-pkgs.drv-0/tmp.wLWcKJIJNw/dist-newstyle/src/8cip0m236_-695ee5a85f6adb4a'...
haskell-project-plan-to-nix-pkgs> remote: Enumerating objects: 12, done.
haskell-project-plan-to-nix-pkgs> remote: Counting objects: 100% (12/12), done.
haskell-project-plan-to-nix-pkgs> remote: Compressing objects: 100% (9/9), done.
haskell-project-plan-to-nix-pkgs> remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 0
haskell-project-plan-to-nix-pkgs> Receiving objects: 100% (12/12), 5.91 KiB | 5.91 MiB/s, done.
haskell-project-plan-to-nix-pkgs> HEAD is now at 7341c79 Minimal Repo For Haskell.Nix
haskell-project-plan-to-nix-pkgs> Warning: The package list for 'hackage.haskell.org' is 19493 days old.
haskell-project-plan-to-nix-pkgs> Run 'cabal update' to get the latest list of available packages.
haskell-project-plan-to-nix-pkgs> Warning: Requested index-state 2023-05-13T12:00:00Z is newer than
haskell-project-plan-to-nix-pkgs> 'hackage.haskell.org'! Falling back to older state (2023-05-11T20:39:33Z).
haskell-project-plan-to-nix-pkgs> Resolving dependencies...
haskell-project-plan-to-nix-pkgs> make-install-plan: dieVerbatim: user error (Error: make-install-plan: Could not resolve dependencies:
haskell-project-plan-to-nix-pkgs> [__0] trying: hls-floskell-plugin-1.0.2.1 (user goal)
haskell-project-plan-to-nix-pkgs> [__1] trying: floskell-0.10.7 (dependency of hls-floskell-plugin)
haskell-project-plan-to-nix-pkgs> [__2] trying: haskell-src-exts-1.23.1 (dependency of floskell)
haskell-project-plan-to-nix-pkgs> [__3] trying: bytestring-0.11.4.0/installed-0.11.4.0 (dependency of floskell)
haskell-project-plan-to-nix-pkgs> [__4] trying: aeson-2.1.2.1 (dependency of floskell)
haskell-project-plan-to-nix-pkgs> [__5] trying: base-4.17.1.0/installed-4.17.1.0 (dependency of
haskell-project-plan-to-nix-pkgs> hls-floskell-plugin)
haskell-project-plan-to-nix-pkgs> [__6] trying: hls-fourmolu-plugin-1.1.1.0 (user goal)
haskell-project-plan-to-nix-pkgs> [__7] trying: fourmolu-0.12.0.0 (dependency of hls-fourmolu-plugin)
haskell-project-plan-to-nix-pkgs> [__8] trying: ghc-lib-parser-9.6.1.20230312 (dependency of fourmolu)
haskell-project-plan-to-nix-pkgs> [__9] trying: hls-hlint-plugin-1.1.2.0 (user goal)
haskell-project-plan-to-nix-pkgs> [_10] trying: hlint-3.5 (dependency of hls-hlint-plugin)
haskell-project-plan-to-nix-pkgs> [_11] rejecting: hlint:+ghc-lib (conflict: ghc-lib-parser==9.6.1.20230312,
haskell-project-plan-to-nix-pkgs> hlint +ghc-lib => ghc-lib-parser>=9.4 && <9.5)
haskell-project-plan-to-nix-pkgs> [_11] rejecting: hlint:-ghc-lib (constraint from project config
haskell-project-plan-to-nix-pkgs> /private/tmp/nix-build-haskell-project-plan-to-nix-pkgs.drv-0/tmp.wLWcKJIJNw/cabal.project
haskell-project-plan-to-nix-pkgs> requires opposite flag selection)
haskell-project-plan-to-nix-pkgs> [_11] fail (backjumping, conflict set: ghc-lib-parser, hlint, hlint:ghc-lib)
haskell-project-plan-to-nix-pkgs> After searching the rest of the dependency tree exhaustively, these were the
haskell-project-plan-to-nix-pkgs> goals I've had most trouble fulfilling: hlint, fourmolu, aeson,
haskell-project-plan-to-nix-pkgs> haskell-src-exts, ghc-lib-parser, bytestring, floskell, hls-fourmolu-plugin,
haskell-project-plan-to-nix-pkgs> base, hls-hlint-plugin, hlint:ghc-lib, hls-floskell-plugin
haskell-project-plan-to-nix-pkgs> )
error: builder for '/nix/store/ijc9168n9ria0b749r57y1jdrb9jb0d8-haskell-project-plan-to-nix-pkgs.drv' failed with exit code 1;

The same HLS pin builds fine without the fourmolu-0.12.0.0 constraint.

I'm not sure how to resolve this. Any ideas?

@brprice
Copy link
Contributor

brprice commented May 17, 2023

This looks like an incompatibility between hlint and fourmolu's dependencies on ghc-lib-parser. We need (quoting latest versions from hackage):

  • hlint requires ghc-lib-parser (>=9.4 && <9.5)
  • fourmolu requires ghc-lib-parser (>=9.6 && <9.7)

This also explains why it builds without the constraint: it can just pick an older version of fourmolu which has compatible bounds with hlint.

I think this will be fixed in the next release of hlint, which will contain ndmitchell/hlint#1470 (already merged upstream). I guess we could build hlint from git?

@dhess
Copy link
Member

dhess commented May 17, 2023

Hmm, so how does anyone get HLS working with fourmolu-0.12.0.0 in that case? Seems like it was premature to merge that support in upstream?

@brprice
Copy link
Contributor

brprice commented May 17, 2023

Hmm, so how does anyone get HLS working with fourmolu-0.12.0.0 in that case? Seems like it was premature to merge that support in upstream?

I imagine that one can have either

  • HLS+hlint+fourmolu-0.11, or
  • HLS+fourmolu-0.12 with no hlint at all

by setting the appropriate flags (for HLS) and constraints (on fourmolu). Just the combination HLS+hlint+fourmolu-0.12 seems problematic (without an unreleased hlint). [Take this with a pinch of salt, I haven't tested anything]

@georgefst
Copy link
Contributor Author

Yes, I believe @brprice is correct. I've asked HLint about making a release: ndmitchell/hlint#1477 (comment).

There are a few options:

@dhess
Copy link
Member

dhess commented May 17, 2023

As this doesn't fix @georgefst's issues, I don't see any point in changing our pin for now, then. We'll wait for, at the latest, the HLS 2.0 release, and hopefully that will fix all the things.

@dhess
Copy link
Member

dhess commented May 22, 2023

Not sure whether this is fixed in 2.0 because it has other issues: #1009

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

No branches or pull requests

3 participants