Proto: use return_*

for * in unit none some true false
This commit is contained in:
Raphaël Proust 2019-01-03 07:58:57 +07:00 committed by Benjamin Canou
parent 618082ed18
commit 1767fcc861
7 changed files with 11 additions and 12 deletions

View File

@ -267,7 +267,7 @@ let commands () =
begin begin
if MBytes.get bytes 0 != '\005' then if MBytes.get bytes 0 != '\005' then
failwith "Not a piece of packed Michelson data (must start with `0x05`)" failwith "Not a piece of packed Michelson data (must start with `0x05`)"
else return () else return_unit
end >>=? fun () -> end >>=? fun () ->
(* Remove first byte *) (* Remove first byte *)
let bytes = MBytes.sub bytes 1 ((MBytes.length bytes) - 1) in let bytes = MBytes.sub bytes 1 ((MBytes.length bytes) - 1) in

View File

@ -707,13 +707,12 @@ let shell_prevalidation
f "Shell-side validation: error while prevalidating operations:@\n%a" f "Shell-side validation: error while prevalidating operations:@\n%a"
-% t event "built_invalid_block_error" -% t event "built_invalid_block_error"
-% a errs_tag errs) >>= fun () -> -% a errs_tag errs) >>= fun () ->
return None return_none
| Ok (shell_header, operations) -> | Ok (shell_header, operations) ->
let raw_ops = let raw_ops =
List.map (fun l -> List.map (fun l ->
List.map snd l.Preapply_result.applied) operations in List.map snd l.Preapply_result.applied) operations in
return return_some (bi, priority, shell_header, raw_ops, delegate, seed_nonce_hash)
(Some (bi, priority, shell_header, raw_ops, delegate, seed_nonce_hash))
let filter_outdated_endorsements expected_level ops = let filter_outdated_endorsements expected_level ops =
List.filter (function List.filter (function
@ -934,7 +933,7 @@ let build_block
-% a timestamp_tag timestamp) >>= fun () -> -% a timestamp_tag timestamp) >>= fun () ->
finalize_block_header final_context ~timestamp validation_result operations >>=? fun shell_header -> finalize_block_header final_context ~timestamp validation_result operations >>=? fun shell_header ->
let raw_ops = List.map (List.map forge) operations in let raw_ops = List.map (List.map forge) operations in
return (Some (bi, priority, shell_header, raw_ops, delegate, seed_nonce_hash)) return_some (bi, priority, shell_header, raw_ops, delegate, seed_nonce_hash)
let previously_baked_level cctxt pkh new_lvl = let previously_baked_level cctxt pkh new_lvl =
State.get cctxt pkh >>=? function State.get cctxt pkh >>=? function

View File

@ -212,7 +212,7 @@ let rec longer_than l n =
let record_proposals ctxt delegate proposals = let record_proposals ctxt delegate proposals =
begin match proposals with begin match proposals with
| [] -> fail Empty_proposal | [] -> fail Empty_proposal
| _ :: _ -> return () | _ :: _ -> return_unit
end >>=? fun () -> end >>=? fun () ->
Vote.get_current_period_kind ctxt >>=? function Vote.get_current_period_kind ctxt >>=? function
| Proposal -> | Proposal ->

View File

@ -297,7 +297,7 @@ module Delegate = struct
| None -> | None ->
(* This case is only when called from `set_active`, when creating (* This case is only when called from `set_active`, when creating
a contract. *) a contract. *)
return false return_false
let add_amount c delegate amount = let add_amount c delegate amount =
ensure_inited c delegate >>=? fun c -> ensure_inited c delegate >>=? fun c ->

View File

@ -1617,7 +1617,7 @@ and parse_instr
let log_stack ctxt loc stack_ty aft = let log_stack ctxt loc stack_ty aft =
match type_logger, script_instr with match type_logger, script_instr with
| None, _ | None, _
| Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return () | Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return_unit
| Some log, (Prim _ | Seq _) -> | Some log, (Prim _ | Seq _) ->
(* Unparsing for logging done in an unlimited context as this (* Unparsing for logging done in an unlimited context as this
is used only by the client and not the protocol *) is used only by the client and not the protocol *)
@ -1625,7 +1625,7 @@ and parse_instr
unparse_stack ctxt stack_ty >>=? fun (stack_ty, _) -> unparse_stack ctxt stack_ty >>=? fun (stack_ty, _) ->
unparse_stack ctxt aft >>=? fun (aft, _) -> unparse_stack ctxt aft >>=? fun (aft, _) ->
log loc stack_ty aft; log loc stack_ty aft;
return () return_unit
in in
let return : let return :
context -> bef judgement -> (bef judgement * context) tzresult Lwt.t = fun ctxt judgement -> context -> bef judgement -> (bef judgement * context) tzresult Lwt.t = fun ctxt judgement ->

View File

@ -111,8 +111,8 @@ let register () =
register0 S.current_proposal begin fun ctxt () () -> register0 S.current_proposal begin fun ctxt () () ->
(* this would be better implemented using get_option in get_current_proposal *) (* this would be better implemented using get_option in get_current_proposal *)
Vote.get_current_proposal ctxt >>= function Vote.get_current_proposal ctxt >>= function
| Ok p -> return (Some p) | Ok p -> return_some p
| Error [Raw_context.Storage_error (Missing_key _)] -> return None | Error [Raw_context.Storage_error (Missing_key _)] -> return_none
| (Error _ as e) -> Lwt.return e | (Error _ as e) -> Lwt.return e
end end

View File

@ -557,7 +557,7 @@ let ownership_sender () =
transfer_and_check_balances ~loc:__LOC__ b imcontract_1 contract_2 Tez.one transfer_and_check_balances ~loc:__LOC__ b imcontract_1 contract_2 Tez.one
>>=? fun (b,_) -> >>=? fun (b,_) ->
Incremental.finalize_block b >>=? fun _ -> Incremental.finalize_block b >>=? fun _ ->
return () return_unit
(*********************************************************************) (*********************************************************************)
(** Random transfer *) (** Random transfer *)