SML/NJ incomplete match
- by dimvar
I wonder how people handle nonexhaustive match warnings in the SML/NJ compiler. For example, I may define a datatype
datatype DT = FOO of int | BAR of string
and then have a function that I know only takes FOOs
fun baz (FOO n) = n + 1
The compiler will give a warning
stdIn:1.5-1.24 Warning: match nonexhaustive
FOO n = ...
val baz = fn : DT - int
I don't wanna see warnings for incomplete matches I did on purpose, because then I have to scan through the output to find a warning that might actually be a bug. I can write the function like this
fun baz (FOO n) = n + 1
| baz _ = raise Fail "baz"
but this clutters the code. What do people usually do in this situation?