sml抑制故意非穷举模式匹配的警告

时间:2013-03-15 23:40:16

标签: sml

假设我有一个类似的数据类型:

datatype location = Safe of string | Dangerous of string * int;

在这个假设的例子中,我想编写一个只传递Safe str而不传递Dangerous(str, num)的函数:

fun send_kids (Safe address) = ...

有没有办法压制警告?告诉SML我知道 tis nonexhaustive?

stdIn:1.6-1.29 Warning: match nonexhaustive
          Safe s => ...

1 个答案:

答案 0 :(得分:2)

不直接。你通过在失败案例中详尽无遗来“告诉”SML:

fun sendKinds (Safe address) = ...
  | sendKinds _ = raise Fail "sendKinds"