Shell: minor renaming

Let's be consistent with Lwt (and ourselves).
This commit is contained in:
Grégoire Henry 2017-04-27 16:48:16 +02:00
parent 4bbc97aeb6
commit 90780f3374
5 changed files with 14 additions and 14 deletions

View File

@ -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 =

View File

@ -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)@."

View File

@ -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

View File

@ -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 ->

View File

@ -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 *)