Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=0.27.0
version=0.28.1
profile=conventional
parse-docstrings=true
73 changes: 36 additions & 37 deletions bench/drivers/identity/inputs/bap_knowledge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,11 @@ module Domain = struct
try
Result.return
@@ Map.merge x y ~f:(fun ~key:_ -> function
| `Left v | `Right v -> Some v
| `Both (x, y) -> (
match join x y with
| Error conflict -> raise @@ Join.Conflict conflict
| Ok z -> Some z))
| `Left v | `Right v -> Some v
| `Both (x, y) -> (
match join x y with
| Error conflict -> raise @@ Join.Conflict conflict
| Ok z -> Some z))
with Join.Conflict err -> Error err
in
let inspect xs =
Expand All @@ -767,9 +767,9 @@ module Domain = struct
let order x y =
Map.symmetric_diff x y ~data_equal:equal
|> Sequence.fold ~init:(0, 0, 0) ~f:(fun (l, m, r) -> function
| _, `Left _ -> (l + 1, m, r)
| _, `Right _ -> (l, m, r + 1)
| _, `Unequal _ -> (l, m + 1, r))
| _, `Left _ -> (l + 1, m, r)
| _, `Right _ -> (l, m, r + 1)
| _, `Unequal _ -> (l, m + 1, r))
|> function
| 0, 0, 0 -> Order.EQ
| 0, 0, _ -> LT
Expand Down Expand Up @@ -1077,9 +1077,8 @@ module Documentation = struct
let classes () =
Hashtbl.to_alist Registry.public
|> List.map ~f:(fun (cls, slots) ->
( (cls, Registry.(find classes) cls),
List.map slots ~f:(fun slot -> (slot, Registry.(find slots) slot))
))
( (cls, Registry.(find classes) cls),
List.map slots ~f:(fun slot -> (slot, Registry.(find slots) slot)) ))

let rules () = Hash_set.to_list Registry.rules
end
Expand Down Expand Up @@ -2882,22 +2881,22 @@ module Knowledge = struct
fun cls ->
Oid.Tree.to_sequence cls.vals
|> Knowledge.Seq.fold ~init:cls ~f:(fun cls (obj, (info : Env.info)) ->
match info.name with
| None -> Knowledge.return cls
| Some sym ->
if not (needs_import cls sym obj) then Knowledge.return cls
else
let obj' =
match Map.find cls.objs { package; name = sym.name } with
| None -> Oid.zero
| Some obj' -> obj'
in
if (not strict) || Oid.(obj' = zero || obj' = obj) then
intern_symbol sym obj cls
else
let info = Oid.Tree.find_exn cls.vals obj' in
let sym' = Option.value_exn info.name in
Knowledge.fail (Import (sym, sym')))
match info.name with
| None -> Knowledge.return cls
| Some sym ->
if not (needs_import cls sym obj) then Knowledge.return cls
else
let obj' =
match Map.find cls.objs { package; name = sym.name } with
| None -> Oid.zero
| Some obj' -> obj'
in
if (not strict) || Oid.(obj' = zero || obj' = obj) then
intern_symbol sym obj cls
else
let info = Oid.Tree.find_exn cls.vals obj' in
let sym' = Option.value_exn info.name in
Knowledge.fail (Import (sym, sym')))

let package_exists package =
Map.exists ~f:(fun { Env.objs } ->
Expand Down Expand Up @@ -3021,7 +3020,7 @@ module Knowledge = struct
fun cls obj ->
Slot.enum cls
|> Base.List.filter ~f:(function Slot.Pack { promises } ->
not (Hashtbl.is_empty promises))
not (Hashtbl.is_empty promises))
|> List.iter ~f:(fun (Slot.Pack s) -> ignore_m @@ collect s obj)

let get_value cls obj =
Expand Down Expand Up @@ -3154,15 +3153,15 @@ module Knowledge = struct
let payload =
Map.to_alist classes
|> List.map ~f:(fun (cid, { Env.vals; last }) ->
let data =
Oid.Tree.to_list vals
|> List.filter_map ~f:(fun (oid, { Env.data; name; comp }) ->
let data = serialize_record data in
let comp = Map.keys comp in
if Array.is_empty data && Option.is_none name then None
else Some { key = oid; sym = name; data; comp })
in
(cid, (last, data)))
let data =
Oid.Tree.to_list vals
|> List.filter_map ~f:(fun (oid, { Env.data; name; comp }) ->
let data = serialize_record data in
let comp = Map.keys comp in
if Array.is_empty data && Option.is_none name then None
else Some { key = oid; sym = name; data; comp })
in
(cid, (last, data)))
in
{ version = V2; payload }

Expand Down
14 changes: 7 additions & 7 deletions bench/drivers/identity/inputs/market_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ module T = struct
| `Auction_indicative_price ->
Auction_indicative_price_event.of_yojson json'
|> Result.map ~f:(fun event ->
`Auction_indicative_price event)
`Auction_indicative_price event)
| `Auction_outcome ->
Auction_outcome_event.of_yojson json'
|> Result.map ~f:(fun event -> `Auction_outcome event))))
Expand Down Expand Up @@ -400,12 +400,12 @@ module T = struct
"socket_sequence" )
in
(match message_type with
| `Heartbeat ->
heartbeat_of_yojson json'
|> Result.map ~f:(fun event -> `Heartbeat event)
| `Update ->
Update.of_yojson json'
|> Result.map ~f:(fun event -> `Update event))
| `Heartbeat ->
heartbeat_of_yojson json'
|> Result.map ~f:(fun event -> `Heartbeat event)
| `Update ->
Update.of_yojson json'
|> Result.map ~f:(fun event -> `Update event))
|> Result.map ~f:(fun message -> { socket_sequence; message })))
| #Yojson.Safe.t as json ->
Result.failf
Expand Down
73 changes: 36 additions & 37 deletions bench/drivers/ppx_sexp_conv/inputs/bap_knowledge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,11 @@ module Domain = struct
try
Result.return
@@ Map.merge x y ~f:(fun ~key:_ -> function
| `Left v | `Right v -> Some v
| `Both (x, y) -> (
match join x y with
| Error conflict -> raise @@ Join.Conflict conflict
| Ok z -> Some z))
| `Left v | `Right v -> Some v
| `Both (x, y) -> (
match join x y with
| Error conflict -> raise @@ Join.Conflict conflict
| Ok z -> Some z))
with Join.Conflict err -> Error err
in
let inspect xs =
Expand All @@ -767,9 +767,9 @@ module Domain = struct
let order x y =
Map.symmetric_diff x y ~data_equal:equal
|> Sequence.fold ~init:(0, 0, 0) ~f:(fun (l, m, r) -> function
| _, `Left _ -> (l + 1, m, r)
| _, `Right _ -> (l, m, r + 1)
| _, `Unequal _ -> (l, m + 1, r))
| _, `Left _ -> (l + 1, m, r)
| _, `Right _ -> (l, m, r + 1)
| _, `Unequal _ -> (l, m + 1, r))
|> function
| 0, 0, 0 -> Order.EQ
| 0, 0, _ -> LT
Expand Down Expand Up @@ -1077,9 +1077,8 @@ module Documentation = struct
let classes () =
Hashtbl.to_alist Registry.public
|> List.map ~f:(fun (cls, slots) ->
( (cls, Registry.(find classes) cls),
List.map slots ~f:(fun slot -> (slot, Registry.(find slots) slot))
))
( (cls, Registry.(find classes) cls),
List.map slots ~f:(fun slot -> (slot, Registry.(find slots) slot)) ))

let rules () = Hash_set.to_list Registry.rules
end
Expand Down Expand Up @@ -2882,22 +2881,22 @@ module Knowledge = struct
fun cls ->
Oid.Tree.to_sequence cls.vals
|> Knowledge.Seq.fold ~init:cls ~f:(fun cls (obj, (info : Env.info)) ->
match info.name with
| None -> Knowledge.return cls
| Some sym ->
if not (needs_import cls sym obj) then Knowledge.return cls
else
let obj' =
match Map.find cls.objs { package; name = sym.name } with
| None -> Oid.zero
| Some obj' -> obj'
in
if (not strict) || Oid.(obj' = zero || obj' = obj) then
intern_symbol sym obj cls
else
let info = Oid.Tree.find_exn cls.vals obj' in
let sym' = Option.value_exn info.name in
Knowledge.fail (Import (sym, sym')))
match info.name with
| None -> Knowledge.return cls
| Some sym ->
if not (needs_import cls sym obj) then Knowledge.return cls
else
let obj' =
match Map.find cls.objs { package; name = sym.name } with
| None -> Oid.zero
| Some obj' -> obj'
in
if (not strict) || Oid.(obj' = zero || obj' = obj) then
intern_symbol sym obj cls
else
let info = Oid.Tree.find_exn cls.vals obj' in
let sym' = Option.value_exn info.name in
Knowledge.fail (Import (sym, sym')))

let package_exists package =
Map.exists ~f:(fun { Env.objs } ->
Expand Down Expand Up @@ -3021,7 +3020,7 @@ module Knowledge = struct
fun cls obj ->
Slot.enum cls
|> Base.List.filter ~f:(function Slot.Pack { promises } ->
not (Hashtbl.is_empty promises))
not (Hashtbl.is_empty promises))
|> List.iter ~f:(fun (Slot.Pack s) -> ignore_m @@ collect s obj)

let get_value cls obj =
Expand Down Expand Up @@ -3154,15 +3153,15 @@ module Knowledge = struct
let payload =
Map.to_alist classes
|> List.map ~f:(fun (cid, { Env.vals; last }) ->
let data =
Oid.Tree.to_list vals
|> List.filter_map ~f:(fun (oid, { Env.data; name; comp }) ->
let data = serialize_record data in
let comp = Map.keys comp in
if Array.is_empty data && Option.is_none name then None
else Some { key = oid; sym = name; data; comp })
in
(cid, (last, data)))
let data =
Oid.Tree.to_list vals
|> List.filter_map ~f:(fun (oid, { Env.data; name; comp }) ->
let data = serialize_record data in
let comp = Map.keys comp in
if Array.is_empty data && Option.is_none name then None
else Some { key = oid; sym = name; data; comp })
in
(cid, (last, data)))
in
{ version = V2; payload }

Expand Down
14 changes: 7 additions & 7 deletions bench/drivers/ppx_sexp_conv/inputs/market_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ module T = struct
| `Auction_indicative_price ->
Auction_indicative_price_event.of_yojson json'
|> Result.map ~f:(fun event ->
`Auction_indicative_price event)
`Auction_indicative_price event)
| `Auction_outcome ->
Auction_outcome_event.of_yojson json'
|> Result.map ~f:(fun event -> `Auction_outcome event))))
Expand Down Expand Up @@ -400,12 +400,12 @@ module T = struct
"socket_sequence" )
in
(match message_type with
| `Heartbeat ->
heartbeat_of_yojson json'
|> Result.map ~f:(fun event -> `Heartbeat event)
| `Update ->
Update.of_yojson json'
|> Result.map ~f:(fun event -> `Update event))
| `Heartbeat ->
heartbeat_of_yojson json'
|> Result.map ~f:(fun event -> `Heartbeat event)
| `Update ->
Update.of_yojson json'
|> Result.map ~f:(fun event -> `Update event))
|> Result.map ~f:(fun message -> { socket_sequence; message })))
| #Yojson.Safe.t as json ->
Result.failf
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(ocamlfind :with-test)
(re (and :with-test (>= 1.9.0)))
(cinaps (and :with-test (>= v0.12.1)))
(ocamlformat (and :with-dev-setup (= 0.26.2))))
(ocamlformat (and :with-dev-setup (= 0.28.1))))
(conflicts
(ocaml-migrate-parsetree (< 2.0.0))
(ocaml-base-compiler (= 5.1.0~alpha1))
Expand Down
2 changes: 1 addition & 1 deletion ppxlib.opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ depends: [
"ocamlfind" {with-test}
"re" {with-test & >= "1.9.0"}
"cinaps" {with-test & >= "v0.12.1"}
"ocamlformat" {with-dev-setup & = "0.26.2"}
"ocamlformat" {with-dev-setup & = "0.28.1"}
"odoc" {with-doc}
]
conflicts: [
Expand Down
16 changes: 8 additions & 8 deletions src/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ let strip_gen_symbol_suffix =
if
chop 1 ~or_more:false string pos (Char.equal '_')
&& chop 3 ~or_more:true string pos (function
| '0' .. '9' -> true
| _ -> false)
| '0' .. '9' -> true
| _ -> false)
&& chop 2 ~or_more:false string pos (Char.equal '_')
then String.prefix string !pos
else string
Expand All @@ -46,17 +46,17 @@ let name_type_params_in_td_res (td : type_declaration) :
in
let name_param i (tp, variance) =
(match tp.ptyp_desc with
| Ptyp_any -> Ok (Ptyp_var (gen_symbol ~prefix:(prefix_string i) ()))
| Ptyp_var _ as v -> Ok v
| _ ->
Error (Location.Error.createf ~loc:tp.ptyp_loc "not a type parameter"))
| Ptyp_any -> Ok (Ptyp_var (gen_symbol ~prefix:(prefix_string i) ()))
| Ptyp_var _ as v -> Ok v
| _ ->
Error (Location.Error.createf ~loc:tp.ptyp_loc "not a type parameter"))
>>| fun ptyp_desc -> ({ tp with ptyp_desc }, variance)
in
let ptype_params, errors =
td.ptype_params |> List.mapi ~f:name_param
|> List.partition_map (function
| Ok o -> Either.Left o
| Error e -> Either.Right e)
| Ok o -> Either.Left o
| Error e -> Either.Right e)
in
match errors with [] -> Ok { td with ptype_params } | t :: q -> Error (t, q)

Expand Down
Loading
Loading