我想处理整数行的限制。我想对所有xPervasives.compare
处理RightInfinity
> Point
x,对.LeftInfinity
在ocaml
REPL 中:
# type open_pt = LeftInfinity | Point of int | RightInfinity
;;
# List.sort Pervasives.compare [LeftInfinity; Point 0; Point 1; RightInfinity]
;;
- : open_pt list = [LeftInfinity; RightInfinity; Point 0; Point 1]
但
# type open_pt = LeftInfinity | Point of int | RightInfinity of unit
;;
# List.sort Pervasives.compare [LeftInfinity; Point 0; Point 1; RightInfinity ()]
;;
- : open_pt list = [LeftInfinity; Point 0; Point 1; RightInfinity ()]
变体首先通过它们的标签进行比较,然后,如果标签相等,则递归地递减到内容。
可以依赖类型声明中变体出现的顺序与标签的顺序之间的任何关系吗?