Skip to content

refactor: remove uses of [Stdune.List] #1480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions ocaml-lsp-server/src/code_actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ let compute_ocaml_code_actions (params : CodeActionParams.t) state doc =
]
in
let batchable, non_batchable =
List.partition_map
~f:(fun ca ->
match ca.run with
| `Batchable f -> Left f
| `Non_batchable f -> Right f)
enabled_actions
List.partition_map enabled_actions ~f:(fun ca ->
match ca.run with
| `Batchable f -> Base.Either.First f
| `Non_batchable f -> Second f)
in
let* batch_results =
if List.is_empty batchable
Expand Down
25 changes: 23 additions & 2 deletions ocaml-lsp-server/src/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,34 @@ include struct
end

module List = struct
include Stdune.List
open Base.List
include Base.List

let compare xs ys ~compare =
Base.List.compare (fun x y -> Ordering.to_int (compare x y)) xs ys
;;

let sort xs ~compare = sort xs ~compare:(fun x y -> Ordering.to_int (compare x y))
let fold_left2 xs ys ~init ~f = Stdlib.List.fold_left2 f init xs ys
let assoc xs key = Assoc.find ~equal:Poly.equal xs key
let assoc_opt xs key = assoc xs key
let mem t x ~equal = mem t x ~equal
let map t ~f = map t ~f
let concat_map t ~f = concat_map t ~f
let flatten t = Stdlib.List.flatten t
let filter_map t ~f = filter_map t ~f
let fold_left t ~init ~f = fold_left t ~init ~f
let findi xs ~f = findi xs ~f
let find_opt xs ~f = find xs ~f

let sort_uniq xs ~compare =
Stdlib.List.sort_uniq (fun x y -> Ordering.to_int (compare x y)) xs
;;

let for_all xs ~f = for_all xs ~f
let find_mapi xs ~f = find_mapi xs ~f
let sub xs ~pos ~len = sub xs ~pos ~len
let hd_exn t = hd_exn t
let hd_opt t = hd t
let nth_exn t n = nth_exn t n
let hd t = hd t
let filter t ~f = filter t ~f
Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ let on_request
match req with
| Client_request.UnknownRequest { meth; params } ->
(match
List.assoc
[ ( Req_switch_impl_intf.meth
, fun ~params state ->
Fiber.of_thunk (fun () ->
Expand All @@ -545,8 +546,7 @@ let on_request
, Semantic_highlighting.Debug.on_request_full )
; ( Req_hover_extended.meth
, fun ~params _ -> Req_hover_extended.on_request ~params rpc )
]
|> List.assoc_opt meth
] meth
with
| None ->
Jsonrpc.Response.Error.raise
Expand Down
4 changes: 1 addition & 3 deletions ocaml-lsp-server/src/workspace_symbol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ let run server (state : State.t) (params : WorkspaceSymbolParams.t) =
| Error `Cancelled -> assert false
| Error (`Exn exn) -> Exn_with_backtrace.reraise exn)
in
List.partition_map symbols_results ~f:(function
| Ok r -> Left r
| Error e -> Right e)
List.partition_result symbols_results
in
let+ () =
match errors with
Expand Down
Loading