Newbie question: Suppress some warnings?

When I build stuff with spago I get lots of warnings. Particular the following two I would like tosupress:

  1. Name f was introduced but not used. and
  2. Module Prelude has unspecified imports, consider using the explicit form…

Is that possible? Also, is this advisable? I think particularly with Prelude it is quite cumbersome to specify all imports, but I’m just a newbie…

You can suppress specific warnings using psa: GitHub - natefaubion/purescript-psa: Error/Warning reporting frontend for the PureScript compiler

The unspecified imports warning only triggers if there is more than one imported module with unspecified imports in a particular module. The idea is that you can import Prelude without having to specify everything you’re using, but other imports should either be qualified or use the explicit form, so that if you come back to this code in a month’s time you are able to track down where everything is coming from.

1 Like

It also protects you from name collisions in the future, as if you’re open-importing multiple modules and some of them come from external libraries, new members being added to these libraries could result in conflicts.

3 Likes

In the PureScript book, a lot of warnings are expected. The book’s code breaks the importing best-practices in several places so that the user doesn’t have to ever edit the imports in the test modules. The aim is that the only edits needed in the test modules is just uncommenting some tests as the code being tested is implemented. The alternatives to just ignoring all the warnings would be to use psa and exclude those 2 expected warnings as Harry suggested, or to take control of the imports in each test module and edit them to import each function one at a time as you implement them.

2 Likes

Thanks for all the responses. Much apreciated!

Taking it all in I might indeed specify all imports explicitly - it will help me to remember better where things are…