package tezos-protocol-alpha
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=43723d096307603703a1a89ed1b2eb202b365f5e7824b96b0cbf813b343a6cf7
sha512=b2a637f2e965000d3d49ad85277ca24d6cb07a1a7cf2bc69d296d8b03ad78c3eaa8e21e94b9162e62c2e11649cd03bc845b2a3dafe623b91065df69d47dc8e4f
doc/tezos-protocol-alpha.raw/Tezos_raw_protocol_alpha/Gas_monad/index.html
Module Tezos_raw_protocol_alpha.Gas_monad
Source
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.
Alias of ('a, 'trace) t
to avoid confusion when the module is open
map f m
maps over successful results of m
using f
.
bind m f
binds successful results of m
and feeds it to f
.
val bind_recover :
('a, 'trace) t ->
(('a, 'trace) Tezos_protocol_environment_alpha.Pervasives.result ->
('b, 'trace') t) ->
('b, 'trace') t
bind_recover m f
binds the result of m
and feeds it to f
. It's another variant of bind
that allows recovery from inner errors.
val of_result :
('a, 'trace) Tezos_protocol_environment_alpha.Pervasives.result ->
('a, 'trace) t
of_result r
is a gas-free embedding of the result r
into the gas monad.
consume_gas c
consumes c amounts of gas. It's a wrapper around Gas.consume
. If that fails, the whole computation within the gas-monad returns an error. See the Alpha_context.Gasmodule
for details.
val run :
Alpha_context.context ->
('a, 'trace) t ->
(('a, 'trace) Tezos_protocol_environment_alpha.Pervasives.result
* Alpha_context.context)
Tezos_protocol_environment_alpha.Error_monad.tzresult
run ctxt m
runs m
using the given context and returns the result along with the new context with updated gas. The given context has unlimited
mode enabled, through Gas.set_unlimited
, no gas is consumed.
val record_trace_eval :
error_details:('error_context, 'error_trace) Script_tc_errors.error_details ->
('error_context -> Tezos_protocol_environment_alpha.Error_monad.error) ->
('a, 'error_trace) t ->
('a, 'error_trace) t
record_trace_level ~error_details f m
returns a new gas-monad value that when run, records trace levels using f
. This function has no effect in the case of a gas-exhaustion error or if error_details
is Fast
.