diff --git a/src/client/embedded/alpha/baker/client_mining_forge.ml b/src/client/embedded/alpha/baker/client_mining_forge.ml index 7d0cce867..0ffc252a9 100644 --- a/src/client/embedded/alpha/baker/client_mining_forge.ml +++ b/src/client/embedded/alpha/baker/client_mining_forge.ml @@ -271,7 +271,7 @@ end = struct | Error _ -> failwith "Json.write_file" | Ok () -> return ()) (fun exn -> - Error_monad.failwith + failwith "could not write the block file: %s." (Printexc.to_string exn)) @@ -377,7 +377,7 @@ let get_unrevealed_nonces cctxt ?(force = false) block = | Some cycle -> Client_mining_blocks.blocks_from_cycle cctxt.rpc_config block cycle >>=? fun blocks -> - map_filter_s (fun hash -> + filter_map_s (fun hash -> Client_proto_nonces.find cctxt hash >>= function | None -> return None | Some nonce -> @@ -466,7 +466,7 @@ let mine cctxt state = let slots = pop_mining_slots state in let seed_nonce = generate_seed_nonce () in let seed_nonce_hash = Nonce.hash seed_nonce in - Error_monad.map_filter_s + filter_map_s (fun (timestamp, (bi, priority, delegate)) -> let block = `Hash bi.Client_mining_blocks.hash in let timestamp = diff --git a/src/client/embedded/alpha/baker/client_mining_main.ml b/src/client/embedded/alpha/baker/client_mining_main.ml index 6d66850f1..1f2834288 100644 --- a/src/client/embedded/alpha/baker/client_mining_main.ml +++ b/src/client/embedded/alpha/baker/client_mining_main.ml @@ -75,7 +75,7 @@ let reveal_block_nonces cctxt ?force block_hashes = Block_hash.pp_short hash >>= fun () -> Lwt.return_none)) block_hashes >>= fun block_infos -> - map_filter_s (fun (bi : Client_mining_blocks.block_info) -> + filter_map_s (fun (bi : Client_mining_blocks.block_info) -> Client_proto_nonces.find cctxt bi.hash >>= function | None -> cctxt.warning "Cannot find nonces for block %a (ignoring)@." diff --git a/src/proto/environment/error_monad.mli b/src/proto/environment/error_monad.mli index 3e3ba17e8..6e76d743c 100644 --- a/src/proto/environment/error_monad.mli +++ b/src/proto/environment/error_monad.mli @@ -99,8 +99,8 @@ val map2_s : ('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list -> 'c list tzresult Lwt.t -(** A {!List.map_filter} in the monad *) -val map_filter_s : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t +(** A {!List.filter_map} in the monad *) +val filter_map_s : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t (** A {!List.fold_left} in the monad *) val fold_left_s : ('a -> 'b -> 'a tzresult Lwt.t) -> 'a -> 'b list -> 'a tzresult Lwt.t diff --git a/src/utils/error_monad.ml b/src/utils/error_monad.ml index e193fbaf8..ebf425b41 100644 --- a/src/utils/error_monad.ml +++ b/src/utils/error_monad.ml @@ -269,22 +269,22 @@ module Make() = struct map2 f t1 t2 >>? fun rt -> Ok (rh :: rt) - let rec map_filter_s f l = + let rec filter_map_s f l = match l with | [] -> return [] | h :: t -> f h >>=? function - | None -> map_filter_s f t + | None -> filter_map_s f t | Some rh -> - map_filter_s f t >>=? fun rt -> + filter_map_s f t >>=? fun rt -> return (rh :: rt) - let rec map_filter_p f l = + let rec filter_map_p f l = match l with | [] -> return [] | h :: t -> let th = f h - and tt = map_filter_s f t in + and tt = filter_map_s f t in th >>=? function | None -> tt | Some rh -> diff --git a/src/utils/error_monad_sig.ml b/src/utils/error_monad_sig.ml index 8afb570d5..0f7a5d190 100644 --- a/src/utils/error_monad_sig.ml +++ b/src/utils/error_monad_sig.ml @@ -134,10 +134,10 @@ module type S = sig ('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list -> 'c list tzresult Lwt.t - (** A {!List.map_filter} in the monad *) - val map_filter_s : + (** A {!List.filter_map} in the monad *) + val filter_map_s : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t - val map_filter_p : + val filter_map_p : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t (** A {!List.fold_left} in the monad *)