package tezos-protocol-011-PtHangz2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t

This monad combines:

  • a state monad where the state is the context
  • two levels of error monad to distinguish gas exhaustion from other errors

It is useful for backtracking on type checking errors without backtracking the consumed gas.

type 'a gas_monad = 'a t

Alias of 'a t to avoid confusion when the module is open

val return : 'a -> 'a t

monadic return operator of the gas monad

val (>>$) : 'a t -> ('a -> 'b t) -> 'b t

Binding operator for the gas monad

val (>|$) : 'a t -> ('a -> 'b) -> 'b t

Mapping operator for the gas monad, m >|$ f is equivalent to m >>$ fun x -> return (f x)

val (>?$) : 'a t -> ('a -> ('b, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result) -> 'b t

Variant of ( >>$ ) to bind uncarbonated functions

val (>??$) : 'a t -> (('a, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result -> 'b t) -> 'b t

Another variant of ( >>$ ) that lets recover from inner errors

val from_tzresult : ('a, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result -> 'a t

gas-free embedding of tzresult values. from_tzresult x is equivalent to return () >?$ fun () -> x

val unsafe_embed : (Alpha_context.context -> ('a * Alpha_context.context, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result) -> 'a t

Open the abstraction barrier to construct an 'a t from a function. This must only be used on functions that can only fail because of gas such as unparse_ty

val gas_consume : Alpha_context.Gas.cost -> unit t

Gas consumption

val run : Alpha_context.context -> 'a t -> (('a, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result * Alpha_context.context, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result

Escaping the gas monad

val record_trace_eval : (unit -> (Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) Stdlib.result) -> 'a t -> 'a t

re-export of Error_monad.record_trace_eval

val get_context : Alpha_context.context t

read the state of the state monad

OCaml

Innovation. Community. Security.