【发布时间】:2020-07-03 13:38:24
【问题描述】:
为什么在最后一行出现binding not exhaustive 警告?
datatype fruit = Apple
datatype sizedFruit = Big of fruit | Small of fruit
val Big x = Big Apple;
我认为绑定是详尽无遗的,因为 RHS 表达式与 LHS 模式匹配,x = Apple 在唯一给定的情况下。因此,我可以安全地忽略这个警告吗?
将第 2 行替换为 datatype sizedFruit = Big of fruit 即可消除警告,但我的实际用例无法承受。提前致谢。
编译器:新泽西标准 ML(64 位)v110.96
【问题讨论】:
标签: pattern-matching sml smlnj ml