[istd] no need to re-implement List.fold_until

Summary: Use `Base.List.fold_until` instead.

Reviewed By: mbouaziz

Differential Revision: D7350958

fbshipit-source-id: a585e80
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 8df15e2f00
commit 57900b11ae

@ -48,21 +48,20 @@ let make_trace_element lt_level lt_loc lt_description lt_node_tags =
type loc_trace = loc_trace_elem list
let compute_local_exception_line loc_trace =
let compute_local_exception_line state step =
match state with
| `Stop _ ->
state
| `Continue (last_known_step_at_level_zero_opt, line_opt) ->
let last_known_step_at_level_zero_opt' =
if Int.equal step.lt_level 0 then Some step else last_known_step_at_level_zero_opt
in
match last_known_step_at_level_zero_opt' with
| Some step_zero when contains_exception step ->
`Stop (last_known_step_at_level_zero_opt', Some step_zero.lt_loc.line)
| _ ->
`Continue (last_known_step_at_level_zero_opt', line_opt)
let open Base.Continue_or_stop in
let compute_local_exception_line (last_known_step_at_level_zero_opt, line_opt) step =
let last_known_step_at_level_zero_opt' =
if Int.equal step.lt_level 0 then Some step else last_known_step_at_level_zero_opt
in
match last_known_step_at_level_zero_opt' with
| Some step_zero when contains_exception step ->
Stop (Some step_zero.lt_loc.line)
| _ ->
Continue (last_known_step_at_level_zero_opt', line_opt)
in
snd (List_.fold_until ~init:(`Continue (None, None)) ~f:compute_local_exception_line loc_trace)
match List.fold_until ~init:(None, None) ~f:compute_local_exception_line loc_trace with
| Finished (_, line_opt) | Stopped_early line_opt ->
line_opt
type node_id_key = {node_id: int; node_key: Caml.Digest.t}

@ -10,14 +10,6 @@
include Core
module List_ = struct
let rec fold_until ~init ~f l =
match (l, init) with
| _, `Stop init' | [], `Continue init' ->
init'
| h :: t, `Continue _ ->
fold_until ~init:(f init h) ~f t
let merge_dedup l1 l2 ~compare =
let rec loop acc l1 l2 =
match (l1, l2) with

Loading…
Cancel
Save