Update for OCaml 4.10 and Core 0.13 (#188)

This commit is contained in:
Rijnard van Tonder 2020-07-04 17:42:52 -07:00 committed by GitHub
parent 0fd6de59b0
commit 3e852c4ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 30 additions and 23 deletions

View File

@ -12,9 +12,9 @@ jobs:
ocaml-version: '4.08.1'
- run: opam pin add comby.dev -n .
- run: opam depext -yt comby
- run: opam install -t . --deps-only
- run: opam pin add -y merlin-lsif https://github.com/rvantonder/merlin.git\#lsif
- run: opam pin add -y lsif-ocaml https://github.com/rvantonder/lsif-ocaml.git
- run: opam exec -- opam install -t . --deps-only
- run: opam exec -- opam pin add -y merlin-lsif https://github.com/rvantonder/merlin.git\#lsif
- run: opam exec -- opam pin add -y lsif-ocaml https://github.com/rvantonder/lsif-ocaml.git
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v1
- run: opam exec -- dune build

View File

@ -24,6 +24,7 @@ depends: [
"oasis"
"tls"
"camlzip"
"shell"
"patdiff"
"lwt_react"
"ppx_deriving_yojson"

View File

@ -1,5 +1,7 @@
open Core
open Polymorphic_compare
open Language
let debug =

View File

@ -2,4 +2,4 @@
(name interactive)
(public_name comby.interactive)
(preprocess (pps ppx_sexp_conv))
(libraries comby.configuration comby.match ppxlib core core.uuid lwt lwt.unix))
(libraries comby.configuration comby.match ppxlib core core.uuid shell.filename_extended lwt lwt.unix))

View File

@ -34,7 +34,7 @@ let pp_line_number ppf start_line =
Format.fprintf ppf "%d:" start_line
let pp ppf (source_path, matches) =
if matches = [] then
if List.is_empty matches then
()
else
let matched =

View File

@ -313,7 +313,7 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
let until_of_from from =
Syntax.user_defined_delimiters
|> List.find_map ~f:(fun (from', until) -> if from = from' then Some until else None)
|> List.find_map ~f:(fun (from', until) -> if String.equal from from' then Some until else None)
|> function
| Some until -> until
| None -> assert false
@ -937,7 +937,7 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
let p = set_start_pos p in
match parse_string' p source (Match.create ()) with
| Success (_, result) ->
if source = "" then
if String.is_empty source then
(* If source is empty and p succeeds, it's the trivial case. We set
the result manually. *)
Ok {
@ -972,7 +972,7 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
make_result @@ begin
to_template template >>= fun p ->
let p =
if template = "" then
if String.is_empty template then
MParser.(eof >> return Unit)
else
p

View File

@ -87,7 +87,7 @@ let all : (module Types.Matcher.S) list =
]
let select_with_extension extension : (module Types.Matcher.S) option =
List.find all ~f:(fun (module M) -> List.exists M.extensions ~f:((=) extension))
List.find all ~f:(fun (module M) -> List.exists M.extensions ~f:(String.(=) extension))
let create
Types.Syntax.

View File

@ -184,7 +184,7 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
let until_of_from from =
Syntax.user_defined_delimiters
|> List.find_map ~f:(fun (from', until) -> if from = from' then Some until else None)
|> List.find_map ~f:(fun (from', until) -> if String.equal from from' then Some until else None)
|> function
| Some until -> until
| None -> assert false
@ -816,7 +816,7 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
let all ?configuration ~template ~source : Match.t list =
configuration_ref := Option.value configuration ~default:!configuration_ref;
matches_ref := [];
if template = "" && source = "" then [trivial]
if String.is_empty template && String.is_empty source then [trivial]
else match first_is_broken template source with
| Ok _
| Error _ -> List.rev !matches_ref

View File

@ -87,7 +87,7 @@ let all : (module Types.Matcher.S) list =
]
let select_with_extension extension : (module Types.Matcher.S) option =
List.find all ~f:(fun (module M) -> List.exists M.extensions ~f:((=) extension))
List.find all ~f:(fun (module M) -> List.exists M.extensions ~f:(String.(=) extension))
let create
Types.Syntax.

View File

@ -108,7 +108,7 @@ module Deprecate = struct
option `End_of_input
(peek_string (String.length reserved_sequence)
>>= fun s ->
if s = reserved_sequence then
if String.equal s reserved_sequence then
return `Reserved_sequence
else
acc))

View File

@ -1,5 +1,7 @@
open Core
open Polymorphic_compare
module Syntax = struct
type escapable_string_literals =
{ delimiters : string list

View File

@ -12,7 +12,7 @@ let any_char_except ~reserved =
option `End_of_input
(peek_string (String.length reserved_sequence)
>>= fun s ->
if s = reserved_sequence then
if String.equal s reserved_sequence then
return `Reserved_sequence
else
acc))

View File

@ -88,7 +88,7 @@ let substitute_in_rewrite_template rewrite_template ({ environment; _ } : Match.
}
let all ?source ~rewrite_template matches : result option =
if matches = [] then None else
if List.is_empty matches then None else
match source with
(* in-place substitution *)
| Some source ->

View File

@ -1,5 +1,7 @@
open Core
open Polymorphic_compare
open Match
module In = struct

View File

@ -47,10 +47,10 @@ let bench_diff ~iterations baseline_command new_command =
if debug then Format.printf "time_baseline: %f@." time_baseline;
if debug then Format.printf "time_new: %f@." time_new_command;
let delta_x = 1.0 /. (time_new_command /. time_baseline) in
if delta_x < 1.0 then begin
if Float.(delta_x < 1.0) then begin
let percentage_delta = 1.0 -. delta_x in
Format.printf "SLOWER: %.4fx of master@." delta_x;
if percentage_delta > epsilon_warn then begin
if Float.(percentage_delta > epsilon_warn) then begin
Format.printf
"FAIL: benchmark epsilon exceeded (%.4f > %.4f)@."
percentage_delta epsilon_warn;
@ -63,7 +63,7 @@ let bench_diff ~iterations baseline_command new_command =
end
else
let percentage_delta = delta_x -. 1.0 in
if percentage_delta > epsilon_same then begin
if Float.(percentage_delta > epsilon_same) then begin
Format.printf "PASS: %.4fx faster@." delta_x;
0
end

View File

@ -222,7 +222,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
Format.eprintf "@.WARNING: the GENERIC matcher was used, because a language could not be inferred from the file extension(s). The GENERIC matcher may miss matches. See '-list' to set a matcher for a specific language and to remove this warning.@."
| Some extension ->
let (module M) = configuration.matcher in
if M.name = "Generic" then
if String.equal M.name "Generic" then
Format.eprintf "@.WARNING: the GENERIC matcher was used because I'm unable to guess what language to use for the file extension %s. The GENERIC matcher may miss matches. See '-list' to set a matcher for a specific language and to remove this warning.@." extension
else if debug then Format.eprintf "@.NOTE: the %s matcher was inferred from extension %s. See '-list' to set a matcher for a specific language.@." M.name extension
| None -> ()

View File

@ -9,7 +9,7 @@ let configuration = Configuration.create ~disable_substring_matching:true ~match
let format s =
let s = String.chop_prefix_exn ~prefix:"\n" s in
let leading_indentation = Option.value_exn (String.lfindi s ~f:(fun _ c -> c <> ' ')) in
let leading_indentation = Option.value_exn (String.lfindi s ~f:(fun _ c -> not (Char.equal c ' '))) in
s
|> String.split ~on:'\n'
|> List.map ~f:(Fn.flip String.drop_prefix leading_indentation)

View File

@ -5,7 +5,7 @@ let configuration = Configuration.create ~match_kind:Fuzzy ()
let format s =
let s = String.chop_prefix_exn ~prefix:"\n" s in
let leading_indentation = Option.value_exn (String.lfindi s ~f:(fun _ c -> c <> ' ')) in
let leading_indentation = Option.value_exn (String.lfindi s ~f:(fun _ c -> not (Char.equal c ' '))) in
s
|> String.split ~on:'\n'
|> List.map ~f:(Fn.flip String.drop_prefix leading_indentation)

View File

@ -113,7 +113,7 @@ let configuration = Configuration.create ~match_kind:Fuzzy ()
let format s =
let s = s |> String.chop_prefix_exn ~prefix:"\n" in
let leading_indentation =
Option.value_exn (String.lfindi s ~f:(fun _ c -> c <> ' ')) in
Option.value_exn (String.lfindi s ~f:(fun _ c -> not (Char.equal c ' '))) in
s
|> String.split ~on:'\n'
|> List.map ~f:(Fn.flip String.drop_prefix leading_indentation)

View File

@ -113,7 +113,7 @@ let configuration = Configuration.create ~match_kind:Fuzzy ()
let format s =
let s = s |> String.chop_prefix_exn ~prefix:"\n" in
let leading_indentation =
Option.value_exn (String.lfindi s ~f:(fun _ c -> c <> ' ')) in
Option.value_exn (String.lfindi s ~f:(fun _ c -> not (Char.equal c ' '))) in
s
|> String.split ~on:'\n'
|> List.map ~f:(Fn.flip String.drop_prefix leading_indentation)