structural comparison of variants
问题 I want to deal with limits on the integer number line. I would like to have Pervasives.compare treat RightInfinity > Point x for all x , and the inverse for LeftInfinity . In the 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] but # type open_pt = LeftInfinity | Point of int | RightInfinity of unit ;; # List.sort