2

Is there exist any way to check if my code contains: Non-exhaustive patterns in function ? Maybe some flag for compiler ?

Cactus
  • 27,075
  • 9
  • 69
  • 149
  • 2
    Yes: `-fwarn-incomplete-patterns` or simply `-Wall`. – zakyggaps Mar 19 '16 at 09:50
  • 1
    Also maybe `-fwarn-incomplete-uni-patterns`, which is not included in `-Wall`, if you're worried about patterns in lambdas. – badcook Mar 19 '16 at 09:54
  • 1
    @zakyggaps You should post that as an answer instead of a comment. – Bakuriu Mar 19 '16 at 10:05
  • 1
    Anyway, all compilers for all languages have the `-Wall` option that turns on most warnings. You should compile with that option set. You could even use the `-Werror` flag which will make compilation fail whenever a warning is issued (sometimes you can ignore some warnings, so it may not be applicable to all cases). – Bakuriu Mar 19 '16 at 10:07
  • Thanks you very much! –  Mar 19 '16 at 10:10
  • @Bakuriu Sorry. I was searching for a duplicate but didn't find one. – zakyggaps Mar 19 '16 at 10:29
  • Easy way to see all the options available: open ghci, type `:set -` and hit tab. This is the options for interpreting, not compiling, but all of the "warning" flags are shared between the two, at least. – user2407038 Mar 19 '16 at 18:29

1 Answers1

1

Yes: -fwarn-incomplete-patterns or simply -Wall.

As @badcook hinted in the comment, if you want GHC to also warn non-exhausive patterns in lambdas you should add -fwarn-incomplete-uni-patterns.

zakyggaps
  • 3,070
  • 2
  • 15
  • 25