haskellvisual-studio-codecabalhlint

Issue installing hlint on windows


I'm trying to install hlint on Windows using: cabal install hlint, and I get the following error:

   Preprocessing executable 'hlint' for hlint-1.8.50..
Building executable 'hlint' for hlint-1.8.50..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules:
        Apply
        CmdLine
        HLint
        HSE.All
        HSE.Bracket
        HSE.Evaluate
        HSE.Match
        HSE.NameMatch
        HSE.Type
        HSE.Util
        Hint.All
        Hint.Bracket
        Hint.Duplicate
        Hint.Extensions
        Hint.Import
        Hint.Lambda
        Hint.List
        Hint.ListRec
        Hint.Match
        Hint.Monad
        Hint.Naming
        Hint.Pragma
        Hint.Structure
        Hint.Type
        Hint.Util
        Idea
        Language.Haskell.HLint
        Parallel
        Proof
        Report
        Settings
        Test
        Util
[ 1 of 35] Compiling HSE.Type         ( src\HSE\Type.hs, dist\build\hlint\hlint-tmp\HSE\Type.o )

src\HSE\Type.hs:6:1: error:
    Could not find module `Language.Haskell.Exts.Annotated'
    Perhaps you meant
      Language.Haskell.Exts.Syntax (from haskell-src-exts-1.23.1)
      Language.Haskell.Exts.Pretty (from haskell-src-exts-1.23.1)
      Language.Haskell.Exts.Build (from haskell-src-exts-1.23.1)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
6 | import Language.Haskell.Exts.Annotated as Export hiding (parse, loc, parseFile, paren, Assoc(..))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal.exe: Failed to build hlint-1.8.50. See the build log above for details.

Glorious Glasgow Haskell Compilation System, version 9.2.1, hlint-1.8.50


Solution

  • As per the comment of Neil Mitchell "no released version of HLint can be used with GHC 9.2.1 (since some of its dependencies aren't yet ready)" it is not possible to run HLint with GHC 9.2.1, which is installed by default with Chocolatey and Haskell Platform for Windows.

    However, I found a workaround. I installed GHCup for Windows:

    Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true
    

    GHCup installs with cabal and ghc 8.10.7, which is perfectly compatible with HLint. In order to install HLint I ran:

    cabal update
    cabal install hlint
    

    After that added location of the newly created hlint binary to PATH. And Voilà: Everything worked like a charm!