Stop GHC from warning me about one particular missing template

Say, I would like to be warned about incomplete templates in my code, but sometimes I know about the incompleteness of a template for a certain function, and I know this very well.

Is it still true that the granularity of the GHC warning is per-module, and there is no way to change the warning about a specific function or definition?

+4
source share
1 answer

Yes, it’s still true, but you can get around this using error .

 f (Just a) = show a 

without a case for Nothing gives warnings but adds

 f Nothing = error "f: Nothing supplied as an argument. This shouldn't have happened. Oops." 

gets rid of the warning.

The solution to every task of your task is to give Haskell some code that you think will never be run so that it is quiet.

Please note: I believe that your code should be reliable and cover every possible situation if you cannot prove that this will never happen. I think that work on this restriction is not a good practice.

(You might think that this is a wide-open back door to crack a useful compile-time check and should be stopped with -Wall , but I can confuse my circle with any simple restriction that you would choose, and I think the complete solution to this is problems will essentially solve the problem of stopping, so you should not blame the compiler.)

+6
source

Source: https://habr.com/ru/post/1437695/


All Articles