From 81612824784d78750a7d1cd55179707479c53a2b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 21 Nov 2024 20:56:30 +0000 Subject: [PATCH] refactor: remove more stdune cruft Signed-off-by: Rudi Grinberg Signed-off-by: Rudi Grinberg --- ocaml-lsp-server/src/import.ml | 12 ++++++++---- ocaml-lsp-server/src/position.ml | 5 +---- ocaml-lsp-server/src/range.ml | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ocaml-lsp-server/src/import.ml b/ocaml-lsp-server/src/import.ml index e02857103..aebb10b08 100644 --- a/ocaml-lsp-server/src/import.ml +++ b/ocaml-lsp-server/src/import.ml @@ -1,6 +1,14 @@ (* All modules from [Stdune] should be in the struct below. The modules are listed alphabetically. Try to keep the order. *) +module Poly = struct + let equal = ( = ) + let compare x y = Ordering.of_int (compare x y) + let hash x = Hashtbl.hash x +end + +let sprintf = Printf.sprintf + include struct open Stdune module Code_error = Code_error @@ -8,15 +16,11 @@ include struct module Exn_with_backtrace = Exn_with_backtrace module Int = Int module Table = Table - module Tuple = Tuple module Unix_env = Env module Io = Io module Map = Map module Monoid = Monoid module Pid = Pid - module Poly = Poly - - let sprintf = sprintf end include struct diff --git a/ocaml-lsp-server/src/position.ml b/ocaml-lsp-server/src/position.ml index bc744dec0..ed5c6a71b 100644 --- a/ocaml-lsp-server/src/position.ml +++ b/ocaml-lsp-server/src/position.ml @@ -37,10 +37,7 @@ let ( - ) ({ line; character } : t) (t : t) : t = ;; let abs ({ line; character } : t) : t = { line = abs line; character = abs character } - -let compare ({ line; character } : t) (t : t) : Ordering.t = - Stdune.Tuple.T2.compare Int.compare Int.compare (line, character) (t.line, t.character) -;; +let compare (x : t) (t : t) : Ordering.t = Poly.compare x t let compare_inclusion (t : t) (r : Lsp.Types.Range.t) = match compare t r.start, compare t r.end_ with diff --git a/ocaml-lsp-server/src/range.ml b/ocaml-lsp-server/src/range.ml index 2040e2dc5..dfc456412 100644 --- a/ocaml-lsp-server/src/range.ml +++ b/ocaml-lsp-server/src/range.ml @@ -22,7 +22,7 @@ let contains (x : t) (y : t) = let compare_size (x : t) (y : t) = let dx = Position.(x.end_ - x.start) in let dy = Position.(y.end_ - y.start) in - Tuple.T2.compare Int.compare Int.compare (dx.line, dy.line) (dx.character, dy.character) + Poly.compare (dx.line, dy.line) (dx.character, dy.character) ;; let first_line =