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

Conditionals in package.yaml/cabal files #100

Open
carymrobbins opened this issue Dec 18, 2019 · 2 comments
Open

Conditionals in package.yaml/cabal files #100

carymrobbins opened this issue Dec 18, 2019 · 2 comments

Comments

@carymrobbins
Copy link

Let's imagine we have something like the following in our package.yaml -

  when:
    - condition: flag(prod)
      then:
        ghc-options:
          - -Wall
          - -Werror
      else:
        ghc-options:
          - -Wall

It seems that the first block with -Wall -Werror is used by hsdev even though the prod flag is not set.

This became apparent when redundant import warnings were being reported by hsdev and, because they were turned into errors, did not allow further error checking of other modules to proceed. In fact, what you'd generally want from hsdev, I'd imagine, is that everything to be interpreted as warnings so error checking can continue through the entire project. Otherwise, the file you are checking may not get error highlighting due to a warning produced in some imported source.

Is there a way to deal with this by supplying flags to hsdev? For instance, it would be quite valuable to be able to tell hsdev to use all of the defer flags (explicit is fine) from ghc, e.g.

% ghc --show-options | grep '^-fdefer'
-fdefer-type-errors
-fdefer-typed-holes
-fdefer-out-of-scope-variables

I've tried using hsdev scan --project <path> --tool stack -g -Wwarn but that doesn't seem to get around the -Werror.

@mvoidex
Copy link
Owner

mvoidex commented Dec 18, 2019

Unfortunately hsdev now doesn't support project flags. As a workaround in this particular case you may try specifying --ghc option in hsdev check (and similar) command.
But, of course, general solution should allow passing project's flags to hsdev.

@carymrobbins
Copy link
Author

I'm just surprised that it's defaulting the prod flag to true in my case. I'd think by default, if it didn't support flags, it would just default everything to false. But I'm likely underappreciating the complexity here.

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

No branches or pull requests

2 participants