Skip to content

cabal warnings don't show up #934

Closed
Closed

Description

@emlautarom1

Currently running ghcide on VSCode, typechecker works on a simple project (single executable) but warnings dont.

My .cabal file is:

...

executable MyFancyProject
  main-is:             Main.hs
  build-depends:       base ^>=4.13.0.0
  hs-source-dirs:      app
  default-language:    Haskell2010
  ghc-options:
    -Wall
    -Wincomplete-record-updates

And this is my app/Main.hs:

module Main where

import Data.List (tails)

main :: IO ()
main = putStrLn "Hello, Haskell!"

myf :: Int
myf = 5
  where
    a = case (1 == 1) of 
      True -> 0
      False -> 1
      _ -> 50
    b = 3

When building or with cabal repl I get the expected warnings:

-Wunused-imports: The import of `Data.List` is redundant
-Wunused-top-binds: Defined but not used: `myf`
-Woverlapping-patterns: Pattern match is redundant
-Wunused-local-binds: Defined but not used `b`
...

This is the output I get from running ghcide app/Main.hs

ghcide version: 0.1.0 (GHC: 8.8.3) (PATH: C:\Users\Ryzen\AppData\Roaming\cabal\bin\ghcide.exe)
Ghcide setup tester in C:\Users\Ryzen\Desktop\MyFancyProject.
Report bugs at https://github.com/digital-asset/ghcide/issues

Step 1/6: Finding files to test in C:\Users\Ryzen\Desktop\MyFancyProject  
Found 1 files

Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/6, Cradle 1/1: Implicit cradle for C:\Users\Ryzen\Desktop\MyFancyProject
Cradle {cradleRootDir = "C:\\Users\\Ryzen\\Desktop\\MyFancyProject", cradleOptsProg = CradleAction: Default}

Step 4/6, Cradle 1/1: Loading GHC Session

Step 5/6: Initializing the IDE

Step 6/6: Type checking the files

Completed (1 file worked, 0 files failed)

According to haskell/ghcide#200 the warnings specified in the .cabal file should set the proper warnings, yet I don't see them in my editor.


System specs:

  • OS: Windows 10 v1909
  • GHC: 8.8.3
  • cabal-install: 3.0.0.0

Activity

  1. changed the title [-]cabal warnings don't show up as warnings[/-] [+]cabal warnings don't show up[/+] on Apr 8, 2020
  2. mpickering commented on Apr 8, 2020

    @mpickering
    Contributor

    The issue is that the naive implicit cradle finding logic is failing to identify your project is a cabal project.

    Cradle {cradleRootDir = "C:\\Users\\Ryzen\\Desktop\\MyFancyProject", cradleOptsProg = CradleAction: Default}
    

    If you specify an explicit hie.yaml file then you will see warnings.

  3. emlautarom1 commented on Apr 8, 2020

    @emlautarom1
    Author

    Alright, that somewhat worked but some warnings still don't show up like -Woverlapping-patterns. (I get why, see haskell/ghcide#107)

    Why can't ghcide automatically detect each component (see haskell/ghcide#514) and the appropriate warning/flags? What needs to be done in order to get this functionality?

    As far as I understand, hie-bios is responsible for the component/flags detection, yet in its current state it fails with multiple components/components with flags like warnings (see haskell/hie-bios#122)

  4. mpickering commented on Apr 8, 2020

    @mpickering
    Contributor

    @emlautarom1 See haskell/ghcide#522 for progress in this regard but the short answer is that the build tools do not yet provide the right interface to make this possible without fragile contortions.

    You will have better luck writing a hie.yaml for each of your projects at the moment.

  5. mpickering commented on Apr 8, 2020

    @mpickering
    Contributor

    -Woverlapping-patterns is not enabled because ghcide does not desugar a module, which is when this warning is emitted.

  6. jneira commented on Oct 5, 2020

    @jneira
    Member

    Afaiu all the points mentiones had been fixed in ghcide master, @emlautarom1 feel free to create another specific issue if it is no the case for any of them

  7. transferred this issue fromhaskell/ghcideon Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions