Is there an option to suppress specific warnings in code? I have two use cases in my work project:
My renderer library uses a type-level machinery to render tables in a type-safe way. I don’t annotate toplevel declarations of renderer types as those would usually take about 20 lines of code with all the foralls and constraints. I usually decide to put them into where clauses, but they look better in a toplevel context. I would like to suppress the “no-type-annotation” warning.
Another use case (perhaps I could live with this one) is where my http client library imports a ton of request/response types from http types, and making all the imports explicit again takes already like 5 lines of code. I would like to suppress “implicit import” warning.
Is there such a mechanism, or plans to implement it?
If you use PSA, you can suppress warnings from the output of your build command. Instead of running, e.g., spago build, you can run spago build --purs-args "--censor-codes=MissingTypeDeclaration,<ImplicitImport>" (I don’t know the name of the implicit import warning off-hand - you’d have to replace that with it’s actual name). Then you’ll see build output that looks something like this
saying that it found 3 warnings in your source code, but all were censored.
Note that I use VS Code for my IDE, and it does not suppress the warnings in VS Code, only in the CLI output.
I have not found a way for VS Code to stop showing the yellow underlines. This might be helpful even though it doesn’t solve your problem, but for no type annotations, I think it highlights the entire definition, which can be a little overwhelming for a warning you’re trying to ignore. Sometimes it works better if you include an annotation, but set the whole type to just a wildcard, and then the highlighted warning is just on the wildcard (and you can mouse over it to see the warning, which tells you what the inferred type is, so it can actually be helpful). I don’t recall though how that works with type variables and constraints, so that might not help in your case.
If the compiler can infer a type for a declaration with no type annotation, it probably shouldn’t produce an error when providing a wildcard annotation like that. This might be a bug; if you could put together a minimal reproducing case and report it that would be very much appreciated.
And you can combine the censorWarnings setting with VSCode’s ability to specify your settings on a per-Workspace or per-Folder level.
I have a stack censored (same as those of Adrielus, but also several to do with explicit/implicit imports) in the Workspace file of my more scrap-book / playground-like repos. But the default for my User / Remote level is to have no warnings censored. Can’t trust myself to remember reenable them for each new /or cloned repo where it would matter.
Hey does anybody know how to turn off specific warnings in (neo)vim? I’m looking for the equivalent of the “purescript.censorWarnings” setting in VS Code, but can’t seem to find anything.
Hello from 2024, finally good news! 3 years later some kind soul created a feature request, so now the devs became aware of the problem and there is a possibility it will get fixed.