Improve support for GHC 8.10 and newest HLint

This commit is contained in:
Vaibhav Sagar 2020-04-18 14:29:51 +08:00
parent e3df54f0c9
commit e25b4ff386
2 changed files with 27 additions and 16 deletions

View File

@ -1,12 +1,12 @@
let
haskell-updates = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/tarball/218a3b3651cff1c830927beb504c78f992c08d35";
sha256 = "18zc31lnm7wzagyhhari0qmrlw2iww8yq1s9llgvdyd53ynwchqm";
nixpkgs-src = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/tarball/ce283f055bd625d6ba80a8f5b7315721252ce5a9";
sha256 = "000gpazdj5ih3p9niw2kvrd2lnd2r9ik6xklvmhcgn8lcbngaiv3";
};
in
{ compiler ? "ghc8101"
, jupyterlabAppDir ? null
, nixpkgs ? import haskell-updates {}
, nixpkgs ? import nixpkgs-src {}
, packages ? (_: [])
, pythonPackages ? (_: [])
, rtsopts ? "-M3g -N2"
@ -59,18 +59,13 @@ let
criterion = nixpkgs.haskell.lib.dontCheck super.criterion;
polyparse = nixpkgs.haskell.lib.doJailbreak super.polyparse;
lifted-async = nixpkgs.haskell.lib.doJailbreak super.lifted-async;
doctest = nixpkgs.haskell.lib.doJailbreak (nixpkgs.haskell.lib.appendPatch super.doctest (nixpkgs.fetchpatch {
url = "https://gitlab.haskell.org/ghc/head.hackage/-/raw/5dd85a5b49143caf6ec0df8a72e0c5448f0b53e6/patches/doctest-0.16.2.patch";
sha256 = "176d8lp3ks2l547lz9wz40mkcmijiaw9h55j8nlw9hi61chxn2p2";
}));
language-haskell-extract = nixpkgs.haskell.lib.appendPatch super.language-haskell-extract (nixpkgs.fetchpatch {
url = "https://gitlab.haskell.org/ghc/head.hackage/-/raw/111b91723aa65f6ae1bb3a883ffa3e187b93c951/patches/language-haskell-extract-0.2.4.patch";
sha256 = "1122izp17qzqyjpv905lakpkg6082vnvym9prpzhwzpgxv8pa117";
});
th-expand-syns = nixpkgs.haskell.lib.doJailbreak super.th-expand-syns;
ghc-lib-parser = nixpkgs.haskell.lib.doJailbreak super.ghc-lib-parser;
ghc-lib-parser = super.ghc-lib-parser_8_10_1_20200412;
ghc-lib-parser-ex = nixpkgs.haskell.lib.addBuildDepend super.ghc-lib-parser-ex self.ghc-lib-parser;
hlint = nixpkgs.haskell.lib.doJailbreak super.hlint;
hlint = nixpkgs.haskell.lib.doJailbreak (self.callCabal2nix "hlint" (builtins.fetchTarball {
url = "https://github.com/ndmitchell/hlint/tarball/bcb586a833c7726087bfff885e3e301b6a110fa7";
sha256 = "1k56vgvfgh44qhdcfanhn0hfhibqila7xmnx7rq1hb15nk0lsp44";
}) {});
} // displays self);
});
ihaskellEnv = haskellPackages.ghcWithPackages (self: [ self.ihaskell ] ++ packages self);

View File

@ -8,10 +8,15 @@ import IHaskellPrelude
import Data.Maybe (mapMaybe)
import System.IO.Unsafe (unsafePerformIO)
-- FIXME change this conditional to use the `hlint` version after a new release
#if MIN_VERSION_ghc(8,10,1)
import Language.Haskell.HLint
import SrcLoc (SrcSpan(..), srcSpanStartLine)
#else
import Language.Haskell.Exts hiding (Module)
import Language.Haskell.HLint as HLint
import Language.Haskell.HLint3
#endif
import IHaskell.Types
import IHaskell.Display
@ -191,12 +196,23 @@ showIdea idea =
Just wn ->
Just
Suggest
{ line = srcSpanStartLine $ ideaSpan idea
{ line = getSrcSpanStartLine $ ideaSpan idea
, found = showSuggestion $ ideaFrom idea
, whyNot = showSuggestion wn
, severity = ideaSeverity idea
, suggestion = ideaHint idea
}
where
getSrcSpanStartLine span =
-- FIXME change this conditional to use the `hlint` version after a new release
#if MIN_VERSION_ghc(8,10,1)
case span of
RealSrcSpan realSpan -> srcSpanStartLine realSpan
UnhelpfulSpan _ -> 1
#else
srcSpanStartLine span
#endif
plainSuggestion :: LintSuggestion -> String