Skip to content

Conditionals in package.yaml/cabal files #100

@carymrobbins

Description

@carymrobbins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions