package octez-libs

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file error_monad.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com>                *)
(* Copyright (c) 2023 Trilitech <contact@trili.tech>                         *)
(*                                                                           *)
(*****************************************************************************)

let return = Lwt_result.return

let return_unit = Lwt_result.return ()

let return_none = Lwt_result.return None

let return_some x = Lwt_result.return (Some x)

let return_nil = Lwt_result.return []

let return_true = Lwt_result.return true

let return_false = Lwt_result.return false

let ( >>= ) = Lwt.Infix.( >>= )

let ( >|= ) = Lwt.Infix.( >|= )

let ok = Result.ok

let error e = Error (Tezos_error_monad.TzTrace.make e)

let ( >>? ) = Result.bind

let ( >|? ) x f = Result.map f x

let fail e = Lwt.return (Error (Tezos_error_monad.TzTrace.make e))

let ( >>=? ) = Lwt_result.bind

let ( >|=? ) x f = Lwt_result.map f x

let ( >>?= ) x f = match x with Error _ as e -> Lwt.return e | Ok x -> f x

let ( >|?= ) x f =
  match x with Error _ as e -> Lwt.return e | Ok x -> Lwt.map Result.ok (f x)
OCaml

Innovation. Community. Security.