Skip to content

Commit

Permalink
Upgrade to OCamlformat 0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow committed Jul 20, 2023
1 parent aff2207 commit 272a7b1
Show file tree
Hide file tree
Showing 45 changed files with 251 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.25.1
version=0.26.0
profile=conventional
ocaml-version=4.08.0
break-separators=before
Expand Down
6 changes: 3 additions & 3 deletions bin/build_cmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ let with_metrics ~common f =
; Pp.text "Timers:"
]
@ List.map
~f:
(fun ( timer
, { Metrics.Timer.Measure.cumulative_time; count } ) ->
~f:(fun
(timer, { Metrics.Timer.Measure.cumulative_time; count })
->
Pp.textf "%s - time spent = %.2fs, count = %d" timer
cumulative_time count)
(String.Map.to_list (Metrics.Timer.aggregated_timers ())))));
Expand Down
2 changes: 1 addition & 1 deletion bin/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ val init :
-> t
-> Dune_config.t

(** [examples \[("description", "dune cmd foo"); ...\]] is an [EXAMPLES] manpage
(** [examples [("description", "dune cmd foo"); ...]] is an [EXAMPLES] manpage
section of enumerated examples illustrating how to run the documented
commands. *)
val examples : (string * string) list -> Cmdliner.Manpage.block
Expand Down
4 changes: 2 additions & 2 deletions bin/pkg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ module Lock = struct
lockdir would fail then no side effect takes place. *)
let write_disk_list, summary_pps =
List.map per_context
~f:(fun { Per_context.lock_dir_path; version_preference; solver_env; _ }
->
~f:(fun
{ Per_context.lock_dir_path; version_preference; solver_env; _ } ->
let summary, lock_dir =
Dune_pkg.Opam.solve_lock_dir ~solver_env ~version_preference
~repo_selection opam_file_map
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/configurator/src/v1.mli
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module Pkg_config : sig
val query : t -> package:string -> package_conf option

val query_expr : t -> package:string -> expr:string -> package_conf option
[@@ocaml.deprecated "please use [query_expr_err]"]
[@@ocaml.deprecated "please use [query_expr_err]"]

(** [query_expr_err t ~package ~expr] query pkg-config for the [package].
[expr] may contain a version constraint, for example "gtk+-3.0 >= 3.18".
Expand All @@ -107,7 +107,7 @@ with type configurator := t
module Flags : sig
(** [write_sexp fname s] writes the list of strings [s] to the file [fname] in
an appropriate format so that it can used in [dune] files with
[(:include \[fname\])]. *)
[(:include [fname])]. *)
val write_sexp : string -> string list -> unit

(** [write_lines fname s] writes the list of string [s] to the file [fname]
Expand Down
176 changes: 88 additions & 88 deletions otherlibs/dune-rpc/private/conv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -313,94 +313,94 @@ let check_version ~version ~since ~until _ctx =
let of_sexp : 'a. ('a, values) t -> version:int * int -> Sexp.t -> 'a =
fun t ~version sexp ->
let rec loop : type a k. (a, k) t -> k -> a * k ret =
fun (type a k) (t : (a, k) t) (ctx : k) : (a * k ret) ->
match t with
| Sexp -> (ctx, Values)
| Version (t, { since; until }) ->
check_version ~version ~since ~until ctx;
loop t ctx
| Fdecl t -> loop (Fdecl.get t) ctx
| List t -> (
match ctx with
| List xs -> (List.map xs ~f:(fun x -> discard_values (loop t x)), Values)
| Atom _ -> raise_of_sexp "expected list")
| Pair (x, y) -> (
match ctx with
| List [ a; b ] ->
let a, Values = loop x a in
let b, Values = loop y b in
((a, b), Values)
| _ -> raise_of_sexp "expected field entry")
| Triple (x, y, z) -> (
match ctx with
| List [ a; b; c ] ->
let a, Values = loop x a in
let b, Values = loop y b in
let c, Values = loop z c in
((a, b, c), Values)
| _ -> raise_of_sexp "expected field entry")
| Record (r : (a, fields) t) ->
let (fields : Fields.t) = Fields.of_sexp ctx in
let a, Fields f = loop r fields in
Fields.check_empty f;
(a, Values)
| Field (name, spec) -> (
match spec with
| Required v ->
let field, rest = Fields.required ctx name in
let t, Values = loop v field in
(t, Fields rest)
| Optional v ->
let field, rest = Fields.optional ctx name in
let t =
match field with
| None -> None
| Some f ->
let a, Values = loop v f in
Some a
in
(t, Fields rest))
| Either (x, y) -> (
try
(* TODO share computation somehow *)
let a, x = loop x ctx in
(Left a, x)
with Of_sexp _ ->
let a, y = loop y ctx in
(Right a, y))
| Iso (t, f, _) ->
let a, k = loop t ctx in
(f a, k)
| Iso_result (t, f, _) -> (
let a, k = loop t ctx in
match f a with
| Error exn -> raise exn
| Ok a -> (a, k))
| Both (x, y) ->
let a, Fields k = loop x ctx in
let b, k = loop y k in
((a, b), k)
| Sum (constrs, _) -> (
match ctx with
| List [ Atom head; args ] -> (
match
List.find_map constrs ~f:(fun (Constr c) ->
if head = c.name then
Some
(let a, k = loop c.arg args in
(c.inj a, k))
else None)
with
| None -> raise_of_sexp "invalid constructor name"
| Some p -> p)
| _ -> raise_of_sexp "expected constructor")
| Enum choices -> (
match ctx with
| List _ -> raise_of_sexp "expected list"
| Atom a -> (
match List.assoc choices a with
| None -> raise_of_sexp "unable to read enum"
| Some s -> (s, Values)))
fun (type a k) (t : (a, k) t) (ctx : k) : (a * k ret) ->
match t with
| Sexp -> (ctx, Values)
| Version (t, { since; until }) ->
check_version ~version ~since ~until ctx;
loop t ctx
| Fdecl t -> loop (Fdecl.get t) ctx
| List t -> (
match ctx with
| List xs -> (List.map xs ~f:(fun x -> discard_values (loop t x)), Values)
| Atom _ -> raise_of_sexp "expected list")
| Pair (x, y) -> (
match ctx with
| List [ a; b ] ->
let a, Values = loop x a in
let b, Values = loop y b in
((a, b), Values)
| _ -> raise_of_sexp "expected field entry")
| Triple (x, y, z) -> (
match ctx with
| List [ a; b; c ] ->
let a, Values = loop x a in
let b, Values = loop y b in
let c, Values = loop z c in
((a, b, c), Values)
| _ -> raise_of_sexp "expected field entry")
| Record (r : (a, fields) t) ->
let (fields : Fields.t) = Fields.of_sexp ctx in
let a, Fields f = loop r fields in
Fields.check_empty f;
(a, Values)
| Field (name, spec) -> (
match spec with
| Required v ->
let field, rest = Fields.required ctx name in
let t, Values = loop v field in
(t, Fields rest)
| Optional v ->
let field, rest = Fields.optional ctx name in
let t =
match field with
| None -> None
| Some f ->
let a, Values = loop v f in
Some a
in
(t, Fields rest))
| Either (x, y) -> (
try
(* TODO share computation somehow *)
let a, x = loop x ctx in
(Left a, x)
with Of_sexp _ ->
let a, y = loop y ctx in
(Right a, y))
| Iso (t, f, _) ->
let a, k = loop t ctx in
(f a, k)
| Iso_result (t, f, _) -> (
let a, k = loop t ctx in
match f a with
| Error exn -> raise exn
| Ok a -> (a, k))
| Both (x, y) ->
let a, Fields k = loop x ctx in
let b, k = loop y k in
((a, b), k)
| Sum (constrs, _) -> (
match ctx with
| List [ Atom head; args ] -> (
match
List.find_map constrs ~f:(fun (Constr c) ->
if head = c.name then
Some
(let a, k = loop c.arg args in
(c.inj a, k))
else None)
with
| None -> raise_of_sexp "invalid constructor name"
| Some p -> p)
| _ -> raise_of_sexp "expected constructor")
| Enum choices -> (
match ctx with
| List _ -> raise_of_sexp "expected list"
| Atom a -> (
match List.assoc choices a with
| None -> raise_of_sexp "unable to read enum"
| Some s -> (s, Values)))
in
discard_values (loop t sexp)

Expand Down
3 changes: 2 additions & 1 deletion otherlibs/dune-rpc/private/dune_rpc_private.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ module Client = struct
end

module Make
(Fiber : Fiber_intf.S) (Chan : sig
(Fiber : Fiber_intf.S)
(Chan : sig
type t

val write : t -> Sexp.t list option -> unit Fiber.t
Expand Down
3 changes: 2 additions & 1 deletion otherlibs/dune-rpc/private/dune_rpc_private.mli
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ module Client : sig
end

module Make
(Fiber : Fiber) (Chan : sig
(Fiber : Fiber)
(Chan : sig
type t

val write : t -> Csexp.t list option -> unit Fiber.t
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/dune-site/src/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let eval s =
let vlen = min vlen (len - colon_pos - 1) in
Some (String.sub s (colon_pos + 1) vlen)
else None
[@@inline never]
[@@inline never]

let get_dir ~package ~section = Hashtbl.find_all dirs (package, section)

Expand Down Expand Up @@ -84,7 +84,7 @@ let site ~package ~section ~suffix ~encoded =
| Some d -> relocate_if_needed d :: dirs
in
List.rev_map (fun dir -> Filename.concat dir suffix) dirs
[@@inline never]
[@@inline never]

let sourceroot local =
match eval local with
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/fiber/src/fiber.mli
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ val map_reduce_errors :
-> ('b, 'a) result t

(** [collect_errors f] is:
[fold_errors f ~init:\[\] ~on_error:(fun e l -> e :: l)] *)
[fold_errors f ~init:[] ~on_error:(fun e l -> e :: l)] *)
val collect_errors :
(unit -> 'a t) -> ('a, Exn_with_backtrace.t list) Result.t t

Expand Down
24 changes: 12 additions & 12 deletions otherlibs/fiber/test/fiber_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ let%expect_test "Stream: multiple readers is an error" =
printf "Reader 2 reading\n";
let+ _x = Fiber.Stream.In.read stream in
printf "Reader 2 done\n"))
[@@expect.uncaught_exn
{|
[@@expect.uncaught_exn
{|
("(\"Fiber.Stream.In: already reading\", {})")
Trailing output
---------------
Expand Down Expand Up @@ -780,8 +780,8 @@ let%expect_test "Stream: multiple writers is an error" =
printf "Writer 2 writing\n";
let+ _x = Fiber.Stream.Out.write stream (Some 2) in
printf "Writer 2 done\n"))
[@@expect.uncaught_exn
{|
[@@expect.uncaught_exn
{|
("(\"Fiber.Stream.Out: already writing\", {})")
Trailing output
---------------
Expand All @@ -797,8 +797,8 @@ let%expect_test "Stream: writing on a closed stream is an error" =
in
let* () = Fiber.Stream.Out.write out None in
Fiber.Stream.Out.write out (Some ()))
[@@expect.uncaught_exn
{|
[@@expect.uncaught_exn
{|
("(\"Fiber.Stream.Out: stream output closed\", {})")
Trailing output
---------------
Expand Down Expand Up @@ -858,8 +858,8 @@ let%expect_test "double run a pool" =
let pool = Pool.create () in
Fiber.fork_and_join_unit (fun () -> Pool.run pool) (fun () -> Pool.run pool));
[%expect.unreachable]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]

let%expect_test "run -> stop -> run a pool" =
(* We shouldn't be able to call [Pool.run] again after we already called
Expand All @@ -874,8 +874,8 @@ let%expect_test "run -> stop -> run a pool" =
in
Pool.run pool);
[%expect.unreachable]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]

let%expect_test "stop a pool and then run it" =
(Scheduler.run
Expand Down Expand Up @@ -912,8 +912,8 @@ let%expect_test "nested run in task" =
Fiber.fork_and_join_unit (fun () -> Pool.close pool) (fun () -> Pool.run pool)
);
[%expect.unreachable]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]
[@@expect.uncaught_exn
{| ("(\"Fiber.Pool.run: concurent calls to run aren't allowed\", {})") |}]

let%expect_test "nested tasks" =
(Scheduler.run
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/stdune/src/caller_id.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(** Who called me? *)

(** [get ~skip] returns the first element of the call stack that is not in
[skip]. For instance, [get ~skip:\[__FILE__\]] will return the first call
site outside of the current file. *)
[skip]. For instance, [get ~skip:[__FILE__]] will return the first call site
outside of the current file. *)
val get : skip:string list -> Loc.t option
18 changes: 10 additions & 8 deletions otherlibs/stdune/src/monoid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ module Product3 (A : Basic) (B : Basic) (C : Basic) = Make (struct
(A.combine a1 a2, B.combine b1 b2, C.combine c1 c2)
end)

module Function (A : sig
type t
end)
(M : Basic) =
module Function
(A : sig
type t
end)
(M : Basic) =
Make (struct
type t = A.t -> M.t

Expand Down Expand Up @@ -190,9 +191,10 @@ module Commutative = struct
module Product (A : Basic) (B : Basic) = Make_commutative (Product (A) (B))
module Product3 (A : Basic) (B : Basic) (C : Basic) =
Make_commutative (Product3 (A) (B) (C))
module Function (A : sig
type t
end)
(M : Basic) =
module Function
(A : sig
type t
end)
(M : Basic) =
Make_commutative (Function (A) (M))
end
Loading

0 comments on commit 272a7b1

Please sign in to comment.