Warnings as Errors

I am using spago build but cannot find the option to treat warnings as errors.

There is --purs-args but with purs compile I do not see this option either.

Is there a way to build with warnings treated as errors?

1 Like

You can use psa for this, with the --strict flag. Spago will just try to use it once you have it installed, and you can pass the flag with --purs-args '--strict'

2 Likes

This looks really useful, but I can’t seem to get it working consistently. I have a yarn script which runs

spago bundle-app --purs-args '--strict' --main Test.Main --to dist/app.js

The first time I run the script on a program with an unused import, I get an error:

$ spago bundle-app --purs-args '--strict' --main Test.Main --to dist/app.js
[info] Installation complete.
Compiling Test.Main
[1/1 UnusedImport] test/Main.purs:5:1

  5  import Data.List (List(..))
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  The import of Data.List is redundant

           Src   Lib   All
Warnings   0     0     0  
Errors     1     0     1  
[error] Failed to build.

But if I run the script again, the error goes away:

$ spago bundle-app --purs-args '--strict' --main Test.Main --to dist/app.js
[info] Installation complete.
           Src   Lib   All
Warnings   0     0     0  
Errors     0     0     0  
[info] Build succeeded.

This sort of non-idempotent behaviour is surprising to me – am I doing something wrong? I experimented with the --stash option to psa but that didn’t help.

many thanks
Roly

1 Like