| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | module type S = |
| 12 | sig |
| 13 | type t |
| 14 | val compare : t -> t -> int |
| 15 | end |
| 16 | |
| 17 | module Pair (M:S) (N:S) = struct |
| 18 | type t = M.t * N.t |
| 19 | |
| 20 | let compare (a,b) (a',b') = |
| 21 | let i = M.compare a a' in |
| 22 | if Int.equal i 0 then N.compare b b' |
| 23 | else i |
| 24 | end |
| 25 | |
| 26 | module UnorderedPair (M:S) = struct |
| 27 | type t = M.t * M.t |
| 28 | |
| 29 | let reorder (a,b as p) = |
| 30 | if M.compare a b <= 0 then p else (b,a) |
| 31 | |
| 32 | let compare p p' = |
| 33 | let p = reorder p and p' = reorder p' in |
| 34 | let module P = Pair(M)(M) in P.compare p p' |
| 35 | end |