3
type t1 = A of int * string
和type t2 = A of (int * string)
,它们是不同的还是相同的?OCaml中的这两个类型定义有什么区别
在这种functional programming tutorial,滑动件6,它说
在OCaml中,变体采取多个参数而不是把元组 作为参数:INT *串的A是二FF erent比A(INT *字符串)。 但是这并不重要,除非你被它咬了。
但我除了一对括号之外没有看到任何区别。
这些是两种不同的类型。这已经在SO上被多次询问和回答。这里是例子:http://stackoverflow.com/questions/14818866/int-int-vs-int-int-in-ocaml-sum-type/14819463#14819463 http://stackoverflow.com/questions/10306733/ocaml -constructor-拆包/ 10306865#10306865 –