Skip to content

Commit

Permalink
Merge pull request ocaml#47 from bschommer/compare-module
Browse files Browse the repository at this point in the history
Move infix comparison operators of Z in submodule to avoid shadowing the polymorphic compare (which also works for Z)
  • Loading branch information
antoinemine authored Aug 22, 2019
2 parents 7751059 + 4a43c47 commit fd4903f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
27 changes: 15 additions & 12 deletions z.mlip
Original file line number Diff line number Diff line change
Expand Up @@ -614,24 +614,27 @@ external (~$): int -> t = "ml_z_of_int" @NOALLOC
external ( ** ): t -> int -> t = "ml_z_pow"
(** Power [pow]. *)

val (=): t -> t -> bool
(** Same as [equal]. *)
module Compare : sig

val (<): t -> t -> bool
(** Same as [lt]. *)
val (=): t -> t -> bool
(** Same as [equal]. *)

val (>): t -> t -> bool
(** Same as [gt]. *)
val (<): t -> t -> bool
(** Same as [lt]. *)

val (<=): t -> t -> bool
(** Same as [leq]. *)
val (>): t -> t -> bool
(** Same as [gt]. *)

val (>=): t -> t -> bool
(** Same as [geq]. *)
val (<=): t -> t -> bool
(** Same as [leq]. *)

val (<>): t -> t -> bool
(** [a <> b] is equivalent to [not (equal a b)]. *)
val (>=): t -> t -> bool
(** Same as [geq]. *)

val (<>): t -> t -> bool
(** [a <> b] is equivalent to [not (equal a b)]. *)

end

(** {1 Miscellaneous} *)

Expand Down
15 changes: 9 additions & 6 deletions z.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,14 @@ external (lsl): t -> int -> t = shift_left@ASM
external (asr): t -> int -> t = shift_right@ASM
external (~$): int -> t = "ml_z_of_int" @NOALLOC
external ( ** ): t -> int -> t = "ml_z_pow"
let (=) = equal
let (<) = lt
let (>) = gt
let (<=) = leq
let (>=) = geq
let (<>) a b = not (equal a b)

module Compare = struct
let (=) = equal
let (<) = lt
let (>) = gt
let (<=) = leq
let (>=) = geq
let (<>) a b = not (equal a b)
end

let version = @VERSION

0 comments on commit fd4903f

Please sign in to comment.