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

Add support for finer grained censoring of user defined warnings #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kl0tl
Copy link

@kl0tl kl0tl commented Dec 4, 2020

This pull request adds a --censor-user-defined-warnings=WARNING flag to ignore Warn constraints whose message contains WARNING. It can be specified multiple times to ignore different warnings.

For instance, given this spago.dhall:

{ name = "censor-user-defined-warnings"
, dependencies = [ "effect", "prelude" ]
, packages = https://raw.githubusercontent.com/purescript/package-sets/prepare-0.14/src/packages.dhall
, sources = [ "src/**/*.purs" ]
}

the following program:

-- src/Example.purs
module Example where

import Prelude

import Effect (Effect)
import Prim.TypeError (class Warn, Text)

foo :: Warn (Text "'foo' is deprecated") => Unit
foo = unit

bar :: Warn (Text "'bar' is deprecated") => Unit
bar = unit

main :: Effect Unit
main = pure foo *> pure bar

yields those warnings when compiled with npx spago build:

[1/2 UserDefinedWarning] src/Example.purs:14:1

  14  main :: Effect Unit
      ^^^^^^^^^^^^^^^^^^^
  
  A custom warning occurred while solving type class constraints:
  
    'foo' is deprecated
  
  in value declaration main

[2/2 UserDefinedWarning] src/Example.purs:14:1

  14  main :: Effect Unit
      ^^^^^^^^^^^^^^^^^^^
  
  A custom warning occurred while solving type class constraints:
  
    'bar' is deprecated
  
  in value declaration main

Compiling with npx spago build -u "--censor-user-defined-warnings=\"'foo' is deprecated\"" yields:

[1/1 UserDefinedWarning] src/Example.purs:14:1

  14  main :: Effect Unit
      ^^^^^^^^^^^^^^^^^^^
  
  A custom warning occurred while solving type class constraints:
  
    'bar' is deprecated
  
  in value declaration main

Compiling with npx spago build -u "--strict --censor-user-defined-warnings=\"'foo' is deprecated\" --censor-user-defined-warnings=\"bar\"" yields no warnings.

This doesn’t alter the behaviour of the existing --censor-warnings and --censor-codes=UserDefinedWarning flags: psa --censor-warnings --censor-user-defined-warnings=WARNING still censor all warnings and psa --censor-codes=UserDefinedWarning --censor-user-defined-warnings=WARNING still censor all user defined warnings.

purescript-psa-utils has been updated with the latest Argonaut libraries, which introduces typed errors, on master so I also had to make three small unrelated changes.

@@ -20,7 +20,7 @@
"purescript-foreign-object": "^2.0.0",
"purescript-now": "^4.0.0",
"purescript-datetime": "^4.0.0",
"purescript-psa-utils": "^6.0.0",
"purescript-psa-utils": "kl0tl/purescript-psa-utils#censor-user-defined-warnings",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll point back to a version number once natefaubion/purescript-psa-utils#10 is merged and a new version is released.

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

Successfully merging this pull request may close these issues.

1 participant