我在 OCaml 中有这个简单的代码:
type int_pair = int * int;;
type a = A of int_pair;;
let extract (A x) = x;;
测试我的extract
功能,它似乎工作:
# extract (A (1,2));;
- : int_pair = (1, 2)
我简化了它,所以它只需要一种类型:
type a' = A' of int * int;;
let extract' (A' x) = x;;
但我得到了错误:
Error: The constructor A' expects 2 argument(s),
but is applied here to 1 argument(s)
有趣的是,我可以构造a'
......
# A' (1,2);;
- : a' = A' (1, 2)
...我就是无法解构它们。为什么?