Interface of the protocol of Tezos in Coq Does compile

These are the sources of the interface of the protocol of Tezos imported to Coq by the current development version of coq-of-ocaml. Tezos is a crypto-currency with smart-contracts and an upgradable protocol.

We show the original OCaml code on the left and the imported Coq code on the right. The imported code does compile. Warnings reported on the OCaml side are due to either various incompleteness in our tool, or to side-effects in the source code. Go on the Gitter chat for more information. Work currently made at Nomadic Labs.

To install the latest development version of coq-of-ocaml with opam:

opam repo add coq-released https://coq.inria.fr/opam/released
opam pin add https://github.com/clarus/coq-of-ocaml.git#master
  • OCaml size: 6154 lines
  • Coq size: 3444 lines (-45% compared to OCaml)
  • Warnings from coq-of-ocaml: 47

Environment_mli

  • OCaml size: 6154 lines
  • Coq size: 3444 lines (-45% compared to OCaml)
environment.mli 47 warnings
module Pervasives : sig
# 1 "../lib_protocol_environment/sigs/v1/pervasives.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(* TEZOS CHANGES

   * Import version 4.06.1
   * Remove [channel], [exit], ...
   * Remove polymorphic comparisons
   * Remove floating-point arithmetic
   * Remove string conversion functions for float
   * Remove deprecated functions

*)

(** The initially opened module.

    This module provides the basic operations over the built-in types
    (numbers, booleans, byte sequences, strings, exceptions, references,
    lists, arrays, input-output channels, ...).

    This module is automatically opened at the beginning of each compilation.
    All components of this module can therefore be referred by their short
    name, without prefixing them by [Pervasives].
*)

(** {1 Exceptions} *)

(** Raise the given exception value *)
external raise : exn -> 'a = "%raise"

(** A faster version [raise] which does not record the backtrace.
    @since 4.02.0
*)
external raise_notrace : exn -> 'a = "%raise_notrace"

(** Raise exception [Invalid_argument] with the given string. *)
val invalid_arg : string -> 'a

(** Raise exception [Failure] with the given string. *)
val failwith : string -> 'a

(** The [Exit] exception is not raised by any library function.  It is
    provided for use in your programs. *)
exception Exit

(** {1 Boolean operations} *)

(** The boolean negation. *)
external not : bool -> bool = "%boolnot"

(** The boolean 'and'. Evaluation is sequential, left-to-right:
    in [e1 && e2], [e1] is evaluated first, and if it returns [false],
    [e2] is not evaluated at all.
    Right-associative operator at precedence level 3/11. *)
external ( && ) : bool -> bool -> bool = "%sequand"

(** The boolean 'or'. Evaluation is sequential, left-to-right:
    in [e1 || e2], [e1] is evaluated first, and if it returns [true],
    [e2] is not evaluated at all.
    Right-associative operator at precedence level 2/11.
*)
external ( || ) : bool -> bool -> bool = "%sequor"

(** {1 Debugging} *)

(** [__LOC__] returns the location at which this expression appears in
    the file currently being parsed by the compiler, with the standard
    error format of OCaml: "File %S, line %d, characters %d-%d".
    @since 4.02.0
*)
external __LOC__ : string = "%loc_LOC"

(** [__FILE__] returns the name of the file currently being
    parsed by the compiler.
    @since 4.02.0
*)
external __FILE__ : string = "%loc_FILE"

(** [__LINE__] returns the line number at which this expression
    appears in the file currently being parsed by the compiler.
    @since 4.02.0
*)
external __LINE__ : int = "%loc_LINE"

(** [__MODULE__] returns the module name of the file being
    parsed by the compiler.
    @since 4.02.0
*)
external __MODULE__ : string = "%loc_MODULE"

(** [__POS__] returns a tuple [(file,lnum,cnum,enum)], corresponding
    to the location at which this expression appears in the file
    currently being parsed by the compiler. [file] is the current
    filename, [lnum] the line number, [cnum] the character position in
    the line and [enum] the last character position in the line.
    @since 4.02.0
*)
external __POS__ : string * int * int * int = "%loc_POS"

(** [__LOC_OF__ expr] returns a pair [(loc, expr)] where [loc] is the
    location of [expr] in the file currently being parsed by the
    compiler, with the standard error format of OCaml: "File %S, line
    %d, characters %d-%d".
    @since 4.02.0
*)
external __LOC_OF__ : 'a -> string * 'a = "%loc_LOC"

(** [__LINE__ expr] returns a pair [(line, expr)], where [line] is the
    line number at which the expression [expr] appears in the file
    currently being parsed by the compiler.
    @since 4.02.0
*)
external __LINE_OF__ : 'a -> int * 'a = "%loc_LINE"

(** [__POS_OF__ expr] returns a pair [(loc,expr)], where [loc] is a
    tuple [(file,lnum,cnum,enum)] corresponding to the location at
    which the expression [expr] appears in the file currently being
    parsed by the compiler. [file] is the current filename, [lnum] the
    line number, [cnum] the character position in the line and [enum]
    the last character position in the line.
    @since 4.02.0
*)
external __POS_OF__ : 'a -> (string * int * int * int) * 'a = "%loc_POS"

(** {1 Composition operators} *)

(** Reverse-application operator: [x |> f |> g] is exactly equivalent
    to [g (f (x))].
    Left-associative operator at precedence level 4/11.
    @since 4.01
*)
external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply"

(** Application operator: [g @@ f @@ x] is exactly equivalent to
    [g (f (x))].
    Right-associative operator at precedence level 5/11.
    @since 4.01
*)
external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"

(** {1 Integer arithmetic} *)

(** Integers are 31 bits wide (or 63 bits on 64-bit processors).
    All operations are taken modulo 2{^31} (or 2{^63}).
    They do not fail on overflow. *)

(** Unary negation. You can also write [- e] instead of [~- e].
    Unary operator at precedence level 9/11 for [- e]
    and 11/11 for [~- e]. *)
external ( ~- ) : int -> int = "%negint"

(** Unary addition. You can also write [+ e] instead of [~+ e].
    Unary operator at precedence level 9/11 for [+ e]
    and 11/11 for [~+ e].
    @since 3.12.0
*)
external ( ~+ ) : int -> int = "%identity"

(** [succ x] is [x + 1]. *)
external succ : int -> int = "%succint"

(** [pred x] is [x - 1]. *)
external pred : int -> int = "%predint"

(** Integer addition.
    Left-associative operator at precedence level 6/11. *)
external ( + ) : int -> int -> int = "%addint"

(** Integer subtraction.
    Left-associative operator at precedence level 6/11. *)
external ( - ) : int -> int -> int = "%subint"

(** Integer multiplication.
    Left-associative operator at precedence level 7/11. *)
external ( * ) : int -> int -> int = "%mulint"

(** Integer division.
    Raise [Division_by_zero] if the second argument is 0.
    Integer division rounds the real quotient of its arguments towards zero.
    More precisely, if [x >= 0] and [y > 0], [x / y] is the greatest integer
    less than or equal to the real quotient of [x] by [y].  Moreover,
    [(- x) / y = x / (- y) = - (x / y)].
    Left-associative operator at precedence level 7/11. *)
external ( / ) : int -> int -> int = "%divint"

(** Integer remainder.  If [y] is not zero, the result
    of [x mod y] satisfies the following properties:
    [x = (x / y) * y + x mod y] and
    [abs(x mod y) <= abs(y) - 1].
    If [y = 0], [x mod y] raises [Division_by_zero].
    Note that [x mod y] is negative only if [x < 0].
    Raise [Division_by_zero] if [y] is zero.
    Left-associative operator at precedence level 7/11. *)
external ( mod ) : int -> int -> int = "%modint"

(** Return the absolute value of the argument.  Note that this may be
    negative if the argument is [min_int]. *)
val abs : int -> int

(** The greatest representable integer. *)
val max_int : int

(** The smallest representable integer. *)
val min_int : int

(** {2 Bitwise operations} *)

(** Bitwise logical and.
    Left-associative operator at precedence level 7/11. *)
external ( land ) : int -> int -> int = "%andint"

(** Bitwise logical or.
    Left-associative operator at precedence level 7/11. *)
external ( lor ) : int -> int -> int = "%orint"

(** Bitwise logical exclusive or.
    Left-associative operator at precedence level 7/11. *)
external ( lxor ) : int -> int -> int = "%xorint"

(** Bitwise logical negation. *)
val lnot : int -> int

(** [n lsl m] shifts [n] to the left by [m] bits.
    The result is unspecified if [m < 0] or [m >= bitsize],
    where [bitsize] is [32] on a 32-bit platform and
    [64] on a 64-bit platform.
    Right-associative operator at precedence level 8/11. *)
external ( lsl ) : int -> int -> int = "%lslint"

(** [n lsr m] shifts [n] to the right by [m] bits.
    This is a logical shift: zeroes are inserted regardless of
    the sign of [n].
    The result is unspecified if [m < 0] or [m >= bitsize].
    Right-associative operator at precedence level 8/11. *)
external ( lsr ) : int -> int -> int = "%lsrint"

(** [n asr m] shifts [n] to the right by [m] bits.
    This is an arithmetic shift: the sign bit of [n] is replicated.
    The result is unspecified if [m < 0] or [m >= bitsize].
    Right-associative operator at precedence level 8/11. *)
external ( asr ) : int -> int -> int = "%asrint"

(** {1 String operations}

    More string operations are provided in module {!String}.
*)

(** String concatenation.
    Right-associative operator at precedence level 5/11. *)
val ( ^ ) : string -> string -> string

(** {1 Character operations}

    More character operations are provided in module {!Char}.
*)

(** Return the ASCII code of the argument. *)
external int_of_char : char -> int = "%identity"

(** Return the character with the given ASCII code.
    Raise [Invalid_argument "char_of_int"] if the argument is
    outside the range 0--255. *)
val char_of_int : int -> char

(** {1 Unit operations} *)

(** Discard the value of its argument and return [()].
    For instance, [ignore(f x)] discards the result of
    the side-effecting function [f].  It is equivalent to
    [f x; ()], except that the latter may generate a
    compiler warning; writing [ignore(f x)] instead
    avoids the warning. *)
external ignore : 'a -> unit = "%ignore"

(** {1 String conversion functions} *)

(** Return the string representation of a boolean. As the returned values
    may be shared, the user should not modify them directly.
*)
val string_of_bool : bool -> string

(** Convert the given string to a boolean.
    Return [None] if the string is not
    ["true"] or ["false"].
    @since 4.05
*)
val bool_of_string_opt : string -> bool option

(** Return the string representation of an integer, in decimal. *)
val string_of_int : int -> string

(** Convert the given string to an integer.
    The string is read in decimal (by default, or if the string
    begins with [0u]), in hexadecimal (if it begins with [0x] or
    [0X]), in octal (if it begins with [0o] or [0O]), or in binary
    (if it begins with [0b] or [0B]).

    The [0u] prefix reads the input as an unsigned integer in the range
    [[0, 2*max_int+1]].  If the input exceeds {!max_int}
    it is converted to the signed integer
    [min_int + input - max_int - 1].

    The [_] (underscore) character can appear anywhere in the string
    and is ignored.

    Return [None] if the given string is not a valid representation of
    an integer, or if the integer represented exceeds the range of
    integers representable in type [int].
    @since 4.05
*)
val int_of_string_opt : string -> int option

(** {1 Pair operations} *)

(** Return the first component of a pair. *)
external fst : 'a * 'b -> 'a = "%field0"

(** Return the second component of a pair. *)
external snd : 'a * 'b -> 'b = "%field1"

(** {1 List operations}

    More list operations are provided in module {!List}.
*)

(** List concatenation.  Not tail-recursive (length of the first argument).
    Right-associative operator at precedence level 5/11. *)
val ( @ ) : 'a list -> 'a list -> 'a list

(** {1 References} *)

(** The type of references (mutable indirection cells) containing
    a value of type ['a]. *)
type 'a ref = {mutable contents : 'a}

(** Return a fresh reference containing the given value. *)
external ref : 'a -> 'a ref = "%makemutable"

(** [!r] returns the current contents of reference [r].
    Equivalent to [fun r -> r.contents].
    Unary operator at precedence level 11/11.*)
external ( ! ) : 'a ref -> 'a = "%field0"

(** [r := a] stores the value of [a] in reference [r].
    Equivalent to [fun r v -> r.contents <- v].
    Right-associative operator at precedence level 1/11. *)
external ( := ) : 'a ref -> 'a -> unit = "%setfield0"

(** Increment the integer contained in the given reference.
    Equivalent to [fun r -> r := succ !r]. *)
external incr : int ref -> unit = "%incr"

(** Decrement the integer contained in the given reference.
    Equivalent to [fun r -> r := pred !r]. *)
external decr : int ref -> unit = "%decr"

(** {1 Result type} *)

(** @since 4.03.0 *)
type ('a, 'b) result = Ok of 'a | Error of 'b

(** {1 Operations on format strings} *)

(** Format strings are character strings with special lexical conventions
    that defines the functionality of formatted input/output functions. Format
    strings are used to read data with formatted input functions from module
    {!Scanf} and to print data with formatted output functions from modules
    {!Printf} and {!Format}.

    Format strings are made of three kinds of entities:
    - {e conversions specifications}, introduced by the special character ['%']
    followed by one or more characters specifying what kind of argument to
    read or print,
    - {e formatting indications}, introduced by the special character ['@']
    followed by one or more characters specifying how to read or print the
    argument,
    - {e plain characters} that are regular characters with usual lexical
    conventions. Plain characters specify string literals to be read in the
    input or printed in the output.

    There is an additional lexical rule to escape the special characters ['%']
    and ['@'] in format strings: if a special character follows a ['%']
    character, it is treated as a plain character. In other words, ["%%"] is
    considered as a plain ['%'] and ["%@"] as a plain ['@'].

    For more information about conversion specifications and formatting
    indications available, read the documentation of modules {!Scanf},
    {!Printf} and {!Format}.
*)

(** Format strings have a general and highly polymorphic type
    [('a, 'b, 'c, 'd, 'e, 'f) format6].
    The two simplified types, [format] and [format4] below are
    included for backward compatibility with earlier releases of
    OCaml.

    The meaning of format string type parameters is as follows:

    - ['a] is the type of the parameters of the format for formatted output
      functions ([printf]-style functions);
      ['a] is the type of the values read by the format for formatted input
      functions ([scanf]-style functions).

    - ['b] is the type of input source for formatted input functions and the
      type of output target for formatted output functions.
      For [printf]-style functions from module {!Printf}, ['b] is typically
      [out_channel];
      for [printf]-style functions from module {!Format}, ['b] is typically
      {!Format.formatter};
      for [scanf]-style functions from module {!Scanf}, ['b] is typically
      {!Scanf.Scanning.in_channel}.

      Type argument ['b] is also the type of the first argument given to
      user's defined printing functions for [%a] and [%t] conversions,
      and user's defined reading functions for [%r] conversion.

    - ['c] is the type of the result of the [%a] and [%t] printing
      functions, and also the type of the argument transmitted to the
      first argument of [kprintf]-style functions or to the
      [kscanf]-style functions.

    - ['d] is the type of parameters for the [scanf]-style functions.

    - ['e] is the type of the receiver function for the [scanf]-style functions.

    - ['f] is the final result type of a formatted input/output function
      invocation: for the [printf]-style functions, it is typically [unit];
      for the [scanf]-style functions, it is typically the result type of the
      receiver function.
*)

type ('a, 'b, 'c, 'd, 'e, 'f) format6 =
  ('a, 'b, 'c, 'd, 'e, 'f) CamlinternalFormatBasics.format6

type ('a, 'b, 'c, 'd) format4 = ('a, 'b, 'c, 'c, 'c, 'd) format6

type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4

(** Converts a format string into a string. *)
val string_of_format : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> string

(** [format_of_string s] returns a format string read from the string
    literal [s].
    Note: [format_of_string] can not convert a string argument that is not a
    literal. If you need this functionality, use the more general
    {!Scanf.format_from_string} function.
*)
external format_of_string :
  ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('a, 'b, 'c, 'd, 'e, 'f) format6
  = "%identity"

(** [f1 ^^ f2] catenates format strings [f1] and [f2]. The result is a
    format string that behaves as the concatenation of format strings [f1] and
    [f2]: in case of formatted output, it accepts arguments from [f1], then
    arguments from [f2]; in case of formatted input, it returns results from
    [f1], then results from [f2].
    Right-associative operator at precedence level 5/11. *)
val ( ^^ ) :
  ('a, 'b, 'c, 'd, 'e, 'f) format6 ->
  ('f, 'b, 'c, 'e, 'g, 'h) format6 ->
  ('a, 'b, 'c, 'd, 'g, 'h) format6
end
open Pervasives
module List : sig
# 1 "../lib_protocol_environment/sigs/v1/list.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(** List operations.

    Some functions are flagged as not tail-recursive.  A tail-recursive
    function uses constant stack space, while a non-tail-recursive function
    uses stack space proportional to the length of its list argument, which
    can be a problem with very long lists.  When the function takes several
    list arguments, an approximate formula giving stack usage (in some
    unspecified constant unit) is shown in parentheses.

    The above considerations can usually be ignored if your lists are not
    longer than about 10000 elements.
*)

(** Return the length (number of elements) of the given list. *)
val length : 'a list -> int

(** Compare the lengths of two lists. [compare_lengths l1 l2] is
    equivalent to [compare (length l1) (length l2)], except that
    the computation stops after itering on the shortest list.
    @since 4.05.0
*)
val compare_lengths : 'a list -> 'b list -> int

(** Compare the length of a list to an integer. [compare_length_with l n] is
    equivalent to [compare (length l) n], except that
    the computation stops after at most [n] iterations on the list.
    @since 4.05.0
*)
val compare_length_with : 'a list -> int -> int

(** [cons x xs] is [x :: xs]
    @since 4.03.0
*)
val cons : 'a -> 'a list -> 'a list

(** Return the first element of the given list. Raise
    [Failure "hd"] if the list is empty. *)
val hd : 'a list -> 'a

(** Return the given list without its first element. Raise
    [Failure "tl"] if the list is empty. *)
val tl : 'a list -> 'a list

(** Return the [n]-th element of the given list.
    The first element (head of the list) is at position 0.
    Return [None] if the list is too short.
    Raise [Invalid_argument "List.nth"] if [n] is negative.
    @since 4.05
*)
val nth_opt : 'a list -> int -> 'a option

(** List reversal. *)
val rev : 'a list -> 'a list

(** [List.init len f] is [f 0; f 1; ...; f (len-1)], evaluated left to right.

    @raise Invalid_argument if len < 0.
    @since 4.06.0
*)
val init : int -> (int -> 'a) -> 'a list

(** Concatenate two lists.  Same as the infix operator [@].
    Not tail-recursive (length of the first argument).  *)
val append : 'a list -> 'a list -> 'a list

(** [List.rev_append l1 l2] reverses [l1] and concatenates it to [l2].
    This is equivalent to {!List.rev}[ l1 @ l2], but [rev_append] is
    tail-recursive and more efficient. *)
val rev_append : 'a list -> 'a list -> 'a list

(** Concatenate a list of lists.  The elements of the argument are all
    concatenated together (in the same order) to give the result.
    Not tail-recursive
    (length of the argument + length of the longest sub-list). *)
val concat : 'a list list -> 'a list

(** An alias for [concat]. *)
val flatten : 'a list list -> 'a list

(** {1 Iterators} *)

(** [List.iter f [a1; ...; an]] applies function [f] in turn to
    [a1; ...; an]. It is equivalent to
    [begin f a1; f a2; ...; f an; () end]. *)
val iter : ('a -> unit) -> 'a list -> unit

(** Same as {!List.iter}, but the function is applied to the index of
    the element as first argument (counting from 0), and the element
    itself as second argument.
    @since 4.00.0
*)
val iteri : (int -> 'a -> unit) -> 'a list -> unit

(** [List.map f [a1; ...; an]] applies function [f] to [a1, ..., an],
    and builds the list [[f a1; ...; f an]]
    with the results returned by [f].  Not tail-recursive. *)
val map : ('a -> 'b) -> 'a list -> 'b list

(** Same as {!List.map}, but the function is applied to the index of
    the element as first argument (counting from 0), and the element
    itself as second argument.  Not tail-recursive.
    @since 4.00.0
*)
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list

(** [List.rev_map f l] gives the same result as
    {!List.rev}[ (]{!List.map}[ f l)], but is tail-recursive and
    more efficient. *)
val rev_map : ('a -> 'b) -> 'a list -> 'b list

(** [List.fold_left f a [b1; ...; bn]] is
    [f (... (f (f a b1) b2) ...) bn]. *)
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a

(** [List.fold_right f [a1; ...; an] b] is
    [f a1 (f a2 (... (f an b) ...))].  Not tail-recursive. *)
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b

(** {1 Iterators on two lists} *)

(** [List.iter2 f [a1; ...; an] [b1; ...; bn]] calls in turn
    [f a1 b1; ...; f an bn].
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths. *)
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit

(** [List.map2 f [a1; ...; an] [b1; ...; bn]] is
    [[f a1 b1; ...; f an bn]].
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths.  Not tail-recursive. *)
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list

(** [List.rev_map2 f l1 l2] gives the same result as
    {!List.rev}[ (]{!List.map2}[ f l1 l2)], but is tail-recursive and
    more efficient. *)
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list

(** [List.fold_left2 f a [b1; ...; bn] [c1; ...; cn]] is
    [f (... (f (f a b1 c1) b2 c2) ...) bn cn].
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths. *)
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a

(** [List.fold_right2 f [a1; ...; an] [b1; ...; bn] c] is
    [f a1 b1 (f a2 b2 (... (f an bn c) ...))].
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths.  Not tail-recursive. *)
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c

(** {1 List scanning} *)

(** [for_all p [a1; ...; an]] checks if all elements of the list
    satisfy the predicate [p]. That is, it returns
    [(p a1) && (p a2) && ... && (p an)]. *)
val for_all : ('a -> bool) -> 'a list -> bool

(** [exists p [a1; ...; an]] checks if at least one element of
    the list satisfies the predicate [p]. That is, it returns
    [(p a1) || (p a2) || ... || (p an)]. *)
val exists : ('a -> bool) -> 'a list -> bool

(** Same as {!List.for_all}, but for a two-argument predicate.
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths. *)
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool

(** Same as {!List.exists}, but for a two-argument predicate.
    Raise [Invalid_argument] if the two lists are determined
    to have different lengths. *)
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool

(** [mem a l] is true if and only if [a] is equal
    to an element of [l]. *)
val mem : 'a -> 'a list -> bool

(** Same as {!List.mem}, but uses physical equality instead of structural
    equality to compare list elements. *)
val memq : 'a -> 'a list -> bool

(** {1 List searching} *)

(** [find_opt p l] returns the first element of the list [l] that
    satisfies the predicate [p], or [None] if there is no value that
    satisfies [p] in the list [l].
    @since 4.05 *)
val find_opt : ('a -> bool) -> 'a list -> 'a option

(** [filter p l] returns all the elements of the list [l]
    that satisfy the predicate [p].  The order of the elements
    in the input list is preserved.  *)
val filter : ('a -> bool) -> 'a list -> 'a list

(** [find_all] is another name for {!List.filter}. *)
val find_all : ('a -> bool) -> 'a list -> 'a list

(** [partition p l] returns a pair of lists [(l1, l2)], where
    [l1] is the list of all the elements of [l] that
    satisfy the predicate [p], and [l2] is the list of all the
    elements of [l] that do not satisfy [p].
    The order of the elements in the input list is preserved. *)
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list

(** {1 Association lists} *)

(** [assoc_opt a l] returns the value associated with key [a] in the list of
    pairs [l]. That is,
    [assoc_opt a [ ...; (a,b); ...] = b]
    if [(a,b)] is the leftmost binding of [a] in list [l].
    Returns [None] if there is no value associated with [a] in the
    list [l].
    @since 4.05 *)
val assoc_opt : 'a -> ('a * 'b) list -> 'b option

(** Same as {!List.assoc_opt}, but uses physical equality instead of structural
    equality to compare keys.
    @since 4.05 *)
val assq_opt : 'a -> ('a * 'b) list -> 'b option

(** Same as {!List.assoc}, but simply return true if a binding exists,
    and false if no bindings exist for the given key. *)
val mem_assoc : 'a -> ('a * 'b) list -> bool

(** Same as {!List.mem_assoc}, but uses physical equality instead of
    structural equality to compare keys. *)
val mem_assq : 'a -> ('a * 'b) list -> bool

(** [remove_assoc a l] returns the list of
    pairs [l] without the first pair with key [a], if any.
    Not tail-recursive. *)
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list

(** Same as {!List.remove_assoc}, but uses physical equality instead
    of structural equality to compare keys.  Not tail-recursive. *)
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list

(** {1 Lists of pairs} *)

(** Transform a list of pairs into a pair of lists:
    [split [(a1,b1); ...; (an,bn)]] is [([a1; ...; an], [b1; ...; bn])].
    Not tail-recursive.
*)
val split : ('a * 'b) list -> 'a list * 'b list

(** Transform a pair of lists into a list of pairs:
    [combine [a1; ...; an] [b1; ...; bn]] is
    [[(a1,b1); ...; (an,bn)]].
    Raise [Invalid_argument] if the two lists
    have different lengths.  Not tail-recursive. *)
val combine : 'a list -> 'b list -> ('a * 'b) list

(** {1 Sorting} *)

(** Sort a list in increasing order according to a comparison
    function.  The comparison function must return 0 if its arguments
    compare as equal, a positive integer if the first is greater,
    and a negative integer if the first is smaller (see Array.sort for
    a complete specification).  For example,
    {!Pervasives.compare} is a suitable comparison function.
    The resulting list is sorted in increasing order.
    [List.sort] is guaranteed to run in constant heap space
    (in addition to the size of the result list) and logarithmic
    stack space.

    The current implementation uses Merge Sort. It runs in constant
    heap space and logarithmic stack space.
*)
val sort : ('a -> 'a -> int) -> 'a list -> 'a list

(** Same as {!List.sort}, but the sorting algorithm is guaranteed to
    be stable (i.e. elements that compare equal are kept in their
    original order) .

    The current implementation uses Merge Sort. It runs in constant
    heap space and logarithmic stack space.
*)
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list

(** Same as {!List.sort} or {!List.stable_sort}, whichever is faster
    on typical input. *)
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list

(** Same as {!List.sort}, but also remove duplicates.
    @since 4.02.0 *)
val sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a list

(** Merge two lists:
    Assuming that [l1] and [l2] are sorted according to the
    comparison function [cmp], [merge cmp l1 l2] will return a
    sorted list containing all the elements of [l1] and [l2].
    If several elements compare equal, the elements of [l1] will be
    before the elements of [l2].
    Not tail-recursive (sum of the lengths of the arguments).
*)
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
end
module String : sig
# 1 "../lib_protocol_environment/sigs/v1/string.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(* TEZOS CHANGES

   * Import version 4.06.1
   * Remove unsafe functions
   * Remove deprecated functions (enforcing string immutability)
   * Add binary data extraction functions

*)

(** String operations.

    A string is an immutable data structure that contains a
    fixed-length sequence of (single-byte) characters. Each character
    can be accessed in constant time through its index.

    Given a string [s] of length [l], we can access each of the [l]
    characters of [s] via its index in the sequence. Indexes start at
    [0], and we will call an index valid in [s] if it falls within the
    range [[0...l-1]] (inclusive). A position is the point between two
    characters or at the beginning or end of the string.  We call a
    position valid in [s] if it falls within the range [[0...l]]
    (inclusive). Note that the character at index [n] is between
    positions [n] and [n+1].

    Two parameters [start] and [len] are said to designate a valid
    substring of [s] if [len >= 0] and [start] and [start+len] are
    valid positions in [s].

    OCaml strings used to be modifiable in place, for instance via the
    {!String.set} and {!String.blit} functions described below. This
    usage is deprecated and only possible when the compiler is put in
    "unsafe-string" mode by giving the [-unsafe-string] command-line
    option (which is currently the default for reasons of backward
    compatibility). This is done by making the types [string] and
    [bytes] (see module {!Bytes}) interchangeable so that functions
    expecting byte sequences can also accept strings as arguments and
    modify them.

    All new code should avoid this feature and be compiled with the
    [-safe-string] command-line option to enforce the separation between
    the types [string] and [bytes].

*)

(** Return the length (number of characters) of the given string. *)
external length : string -> int = "%string_length"

(** [String.get s n] returns the character at index [n] in string [s].
    You can also write [s.[n]] instead of [String.get s n].

    Raise [Invalid_argument] if [n] not a valid index in [s]. *)
external get : string -> int -> char = "%string_safe_get"

(** [String.make n c] returns a fresh string of length [n],
    filled with the character [c].

    Raise [Invalid_argument] if [n < 0] or [n > ]{!Sys.max_string_length}. *)
val make : int -> char -> string

(** [String.init n f] returns a string of length [n], with character
    [i] initialized to the result of [f i] (called in increasing
    index order).

    Raise [Invalid_argument] if [n < 0] or [n > ]{!Sys.max_string_length}.

    @since 4.02.0
*)
val init : int -> (int -> char) -> string

(** [String.sub s start len] returns a fresh string of length [len],
    containing the substring of [s] that starts at position [start] and
    has length [len].

    Raise [Invalid_argument] if [start] and [len] do not
    designate a valid substring of [s]. *)
val sub : string -> int -> int -> string

(** Same as {!Bytes.blit_string}. *)
val blit : string -> int -> bytes -> int -> int -> unit

(** [String.concat sep sl] concatenates the list of strings [sl],
    inserting the separator string [sep] between each.

    Raise [Invalid_argument] if the result is longer than
    {!Sys.max_string_length} bytes. *)
val concat : string -> string list -> string

(** [String.iter f s] applies function [f] in turn to all
    the characters of [s].  It is equivalent to
    [f s.[0]; f s.[1]; ...; f s.[String.length s - 1]; ()]. *)
val iter : (char -> unit) -> string -> unit

(** Same as {!String.iter}, but the
    function is applied to the index of the element as first argument
    (counting from 0), and the character itself as second argument.
    @since 4.00.0 *)
val iteri : (int -> char -> unit) -> string -> unit

(** [String.map f s] applies function [f] in turn to all the
    characters of [s] (in increasing index order) and stores the
    results in a new string that is returned.
    @since 4.00.0 *)
val map : (char -> char) -> string -> string

(** [String.mapi f s] calls [f] with each character of [s] and its
    index (in increasing index order) and stores the results in a new
    string that is returned.
    @since 4.02.0 *)
val mapi : (int -> char -> char) -> string -> string

(** Return a copy of the argument, without leading and trailing
    whitespace.  The characters regarded as whitespace are: [' '],
    ['\012'], ['\n'], ['\r'], and ['\t'].  If there is neither leading nor
    trailing whitespace character in the argument, return the original
    string itself, not a copy.
    @since 4.00.0 *)
val trim : string -> string

(** Return a copy of the argument, with special characters
    represented by escape sequences, following the lexical
    conventions of OCaml.
    All characters outside the ASCII printable range (32..126) are
    escaped, as well as backslash and double-quote.

    If there is no special character in the argument that needs
    escaping, return the original string itself, not a copy.

    Raise [Invalid_argument] if the result is longer than
    {!Sys.max_string_length} bytes.

    The function {!Scanf.unescaped} is a left inverse of [escaped],
    i.e. [Scanf.unescaped (escaped s) = s] for any string [s] (unless
    [escape s] fails). *)
val escaped : string -> string

(** [String.index_opt s c] returns the index of the first
    occurrence of character [c] in string [s], or
    [None] if [c] does not occur in [s].
    @since 4.05 *)
val index_opt : string -> char -> int option

(** [String.rindex_opt s c] returns the index of the last occurrence
    of character [c] in string [s], or [None] if [c] does not occur in
    [s].
    @since 4.05 *)
val rindex_opt : string -> char -> int option

(** [String.index_from_opt s i c] returns the index of the
    first occurrence of character [c] in string [s] after position [i]
    or [None] if [c] does not occur in [s] after position [i].

    [String.index_opt s c] is equivalent to [String.index_from_opt s 0 c].
    Raise [Invalid_argument] if [i] is not a valid position in [s].

    @since 4.05
*)
val index_from_opt : string -> int -> char -> int option

(** [String.rindex_from_opt s i c] returns the index of the
    last occurrence of character [c] in string [s] before position [i+1]
    or [None] if [c] does not occur in [s] before position [i+1].

    [String.rindex_opt s c] is equivalent to
    [String.rindex_from_opt s (String.length s - 1) c].

    Raise [Invalid_argument] if [i+1] is not a valid position in [s].

    @since 4.05
*)
val rindex_from_opt : string -> int -> char -> int option

(** [String.contains s c] tests if character [c]
    appears in the string [s]. *)
val contains : string -> char -> bool

(** [String.contains_from s start c] tests if character [c]
    appears in [s] after position [start].
    [String.contains s c] is equivalent to
    [String.contains_from s 0 c].

    Raise [Invalid_argument] if [start] is not a valid position in [s]. *)
val contains_from : string -> int -> char -> bool

(** [String.rcontains_from s stop c] tests if character [c]
    appears in [s] before position [stop+1].

    Raise [Invalid_argument] if [stop < 0] or [stop+1] is not a valid
    position in [s]. *)
val rcontains_from : string -> int -> char -> bool

(** Return a copy of the argument, with all lowercase letters
    translated to uppercase, using the US-ASCII character set.
    @since 4.03.0 *)
val uppercase_ascii : string -> string

(** Return a copy of the argument, with all uppercase letters
    translated to lowercase, using the US-ASCII character set.
    @since 4.03.0 *)
val lowercase_ascii : string -> string

(** Return a copy of the argument, with the first character set to uppercase,
    using the US-ASCII character set.
    @since 4.03.0 *)
val capitalize_ascii : string -> string

(** Return a copy of the argument, with the first character set to lowercase,
    using the US-ASCII character set.
    @since 4.03.0 *)
val uncapitalize_ascii : string -> string

(** An alias for the type of strings. *)
type t = string

(** The comparison function for strings, with the same specification as
    {!Pervasives.compare}.  Along with the type [t], this function [compare]
    allows the module [String] to be passed as argument to the functors
    {!Set.Make} and {!Map.Make}. *)
val compare : t -> t -> int

(** The equal function for strings.
    @since 4.03.0 *)
val equal : t -> t -> bool

(** [String.split_on_char sep s] returns the list of all (possibly empty)
    substrings of [s] that are delimited by the [sep] character.

    The function's output is specified by the following invariants:

    - The list is not empty.
    - Concatenating its elements using [sep] as a separator returns a
      string equal to the input ([String.concat (String.make 1 sep)
      (String.split_on_char sep s) = s]).
    - No string in the result contains the [sep] character.

    @since 4.04.0
*)
val split_on_char : char -> string -> string list

(** Functions reading bytes  *)

(** [get_char buff i] reads 1 byte at offset i as a char *)
val get_char : t -> int -> char

(** [get_uint8 buff i] reads 1 byte at offset i as an unsigned int of 8
    bits. i.e. It returns a value between 0 and 2^8-1 *)
val get_uint8 : t -> int -> int

(** [get_int8 buff i] reads 1 byte at offset i as a signed int of 8
    bits. i.e. It returns a value between -2^7 and 2^7-1 *)
val get_int8 : t -> int -> int

(** Functions reading according to Big Endian byte order *)

(** [get_uint16 buff i] reads 2 bytes at offset i as an unsigned int
      of 16 bits. i.e. It returns a value between 0 and 2^16-1 *)
val get_uint16 : t -> int -> int

(** [get_int16 buff i] reads 2 byte at offset i as a signed int of
      16 bits. i.e. It returns a value between -2^15 and 2^15-1 *)
val get_int16 : t -> int -> int

(** [get_int32 buff i] reads 4 bytes at offset i as an int32. *)
val get_int32 : t -> int -> int32

(** [get_int64 buff i] reads 8 bytes at offset i as an int64. *)
val get_int64 : t -> int -> int64

module LE : sig
  (** Functions reading according to Little Endian byte order *)

  (** [get_uint16 buff i] reads 2 bytes at offset i as an unsigned int
      of 16 bits. i.e. It returns a value between 0 and 2^16-1 *)
  val get_uint16 : t -> int -> int

  (** [get_int16 buff i] reads 2 byte at offset i as a signed int of
      16 bits. i.e. It returns a value between -2^15 and 2^15-1 *)
  val get_int16 : t -> int -> int

  (** [get_int32 buff i] reads 4 bytes at offset i as an int32. *)
  val get_int32 : t -> int -> int32

  (** [get_int64 buff i] reads 8 bytes at offset i as an int64. *)
  val get_int64 : t -> int -> int64
end
end
module Int32 : sig
# 1 "../lib_protocol_environment/sigs/v1/int32.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(* TEZOS CHANGES

   * Import version 4.06.1
   * Remove deprecated functions

*)

(** 32-bit integers.

    This module provides operations on the type [int32]
    of signed 32-bit integers.  Unlike the built-in [int] type,
    the type [int32] is guaranteed to be exactly 32-bit wide on all
    platforms.  All arithmetic operations over [int32] are taken
    modulo 2{^32}.

    Performance notice: values of type [int32] occupy more memory
    space than values of type [int], and arithmetic operations on
    [int32] are generally slower than those on [int].  Use [int32]
    only when the application requires exact 32-bit arithmetic. *)

(** The 32-bit integer 0. *)
val zero : int32

(** The 32-bit integer 1. *)
val one : int32

(** The 32-bit integer -1. *)
val minus_one : int32

(** Unary negation. *)
external neg : int32 -> int32 = "%int32_neg"

(** Addition. *)
external add : int32 -> int32 -> int32 = "%int32_add"

(** Subtraction. *)
external sub : int32 -> int32 -> int32 = "%int32_sub"

(** Multiplication. *)
external mul : int32 -> int32 -> int32 = "%int32_mul"

(** Integer division.  Raise [Division_by_zero] if the second
    argument is zero.  This division rounds the real quotient of
    its arguments towards zero, as specified for {!Pervasives.(/)}. *)
external div : int32 -> int32 -> int32 = "%int32_div"

(** Integer remainder.  If [y] is not zero, the result
    of [Int32.rem x y] satisfies the following property:
    [x = Int32.add (Int32.mul (Int32.div x y) y) (Int32.rem x y)].
    If [y = 0], [Int32.rem x y] raises [Division_by_zero]. *)
external rem : int32 -> int32 -> int32 = "%int32_mod"

(** Successor.  [Int32.succ x] is [Int32.add x Int32.one]. *)
val succ : int32 -> int32

(** Predecessor.  [Int32.pred x] is [Int32.sub x Int32.one]. *)
val pred : int32 -> int32

(** Return the absolute value of its argument. *)
val abs : int32 -> int32

(** The greatest representable 32-bit integer, 2{^31} - 1. *)
val max_int : int32

(** The smallest representable 32-bit integer, -2{^31}. *)
val min_int : int32

(** Bitwise logical and. *)
external logand : int32 -> int32 -> int32 = "%int32_and"

(** Bitwise logical or. *)
external logor : int32 -> int32 -> int32 = "%int32_or"

(** Bitwise logical exclusive or. *)
external logxor : int32 -> int32 -> int32 = "%int32_xor"

(** Bitwise logical negation. *)
val lognot : int32 -> int32

(** [Int32.shift_left x y] shifts [x] to the left by [y] bits.
    The result is unspecified if [y < 0] or [y >= 32]. *)
external shift_left : int32 -> int -> int32 = "%int32_lsl"

(** [Int32.shift_right x y] shifts [x] to the right by [y] bits.
    This is an arithmetic shift: the sign bit of [x] is replicated
    and inserted in the vacated bits.
    The result is unspecified if [y < 0] or [y >= 32]. *)
external shift_right : int32 -> int -> int32 = "%int32_asr"

(** [Int32.shift_right_logical x y] shifts [x] to the right by [y] bits.
    This is a logical shift: zeroes are inserted in the vacated bits
    regardless of the sign of [x].
    The result is unspecified if [y < 0] or [y >= 32]. *)
external shift_right_logical : int32 -> int -> int32 = "%int32_lsr"

(** Convert the given integer (type [int]) to a 32-bit integer
    (type [int32]). *)
external of_int : int -> int32 = "%int32_of_int"

(** Convert the given 32-bit integer (type [int32]) to an
    integer (type [int]).  On 32-bit platforms, the 32-bit integer
    is taken modulo 2{^31}, i.e. the high-order bit is lost
    during the conversion.  On 64-bit platforms, the conversion
    is exact. *)
external to_int : int32 -> int = "%int32_to_int"

(** Convert the given floating-point number to a 32-bit integer,
    discarding the fractional part (truncate towards 0).
    The result of the conversion is undefined if, after truncation,
    the number is outside the range \[{!Int32.min_int}, {!Int32.max_int}\]. *)
external of_float : float -> int32
  = "caml_int32_of_float" "caml_int32_of_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Convert the given 32-bit integer to a floating-point number. *)
external to_float : int32 -> float
  = "caml_int32_to_float" "caml_int32_to_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Convert the given string to a 32-bit integer.
    The string is read in decimal (by default, or if the string
    begins with [0u]) or in hexadecimal, octal or binary if the
    string begins with [0x], [0o] or [0b] respectively.

    The [0u] prefix reads the input as an unsigned integer in the range
    [[0, 2*Int32.max_int+1]].  If the input exceeds {!Int32.max_int}
    it is converted to the signed integer
    [Int32.min_int + input - Int32.max_int - 1].

    The [_] (underscore) character can appear anywhere in the string
    and is ignored.
    Raise [Failure "Int32.of_string"] if the given string is not
    a valid representation of an integer, or if the integer represented
    exceeds the range of integers representable in type [int32]. *)
external of_string : string -> int32 = "caml_int32_of_string"

(** Same as [of_string], but return [None] instead of raising.
    @since 4.05 *)
val of_string_opt : string -> int32 option

(** Return the string representation of its argument, in signed decimal. *)
val to_string : int32 -> string

(** Return the internal representation of the given float according
    to the IEEE 754 floating-point 'single format' bit layout.
    Bit 31 of the result represents the sign of the float;
    bits 30 to 23 represent the (biased) exponent; bits 22 to 0
    represent the mantissa. *)
external bits_of_float : float -> int32
  = "caml_int32_bits_of_float" "caml_int32_bits_of_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Return the floating-point number whose internal representation,
    according to the IEEE 754 floating-point 'single format' bit layout,
    is the given [int32]. *)
external float_of_bits : int32 -> float
  = "caml_int32_float_of_bits" "caml_int32_float_of_bits_unboxed"
  [@@unboxed] [@@noalloc]

(** An alias for the type of 32-bit integers. *)
type t = int32

(** The comparison function for 32-bit integers, with the same specification as
    {!Pervasives.compare}.  Along with the type [t], this function [compare]
    allows the module [Int32] to be passed as argument to the functors
    {!Set.Make} and {!Map.Make}. *)
val compare : t -> t -> int

(** The equal function for int32s.
    @since 4.03.0 *)
val equal : t -> t -> bool
end
module Int64 : sig
# 1 "../lib_protocol_environment/sigs/v1/int64.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(* TEZOS CHANGES

   * Import version 4.06.1
   * Remove deprecated functions

*)
(** 64-bit integers.

    This module provides operations on the type [int64] of
    signed 64-bit integers.  Unlike the built-in [int] type,
    the type [int64] is guaranteed to be exactly 64-bit wide on all
    platforms.  All arithmetic operations over [int64] are taken
    modulo 2{^64}

    Performance notice: values of type [int64] occupy more memory
    space than values of type [int], and arithmetic operations on
    [int64] are generally slower than those on [int].  Use [int64]
    only when the application requires exact 64-bit arithmetic.
*)

(** The 64-bit integer 0. *)
val zero : int64

(** The 64-bit integer 1. *)
val one : int64

(** The 64-bit integer -1. *)
val minus_one : int64

(** Unary negation. *)
external neg : int64 -> int64 = "%int64_neg"

(** Addition. *)
external add : int64 -> int64 -> int64 = "%int64_add"

(** Subtraction. *)
external sub : int64 -> int64 -> int64 = "%int64_sub"

(** Multiplication. *)
external mul : int64 -> int64 -> int64 = "%int64_mul"

(** Integer division.  Raise [Division_by_zero] if the second
    argument is zero.  This division rounds the real quotient of
    its arguments towards zero, as specified for {!Pervasives.(/)}. *)
external div : int64 -> int64 -> int64 = "%int64_div"

(** Integer remainder.  If [y] is not zero, the result
    of [Int64.rem x y] satisfies the following property:
    [x = Int64.add (Int64.mul (Int64.div x y) y) (Int64.rem x y)].
    If [y = 0], [Int64.rem x y] raises [Division_by_zero]. *)
external rem : int64 -> int64 -> int64 = "%int64_mod"

(** Successor.  [Int64.succ x] is [Int64.add x Int64.one]. *)
val succ : int64 -> int64

(** Predecessor.  [Int64.pred x] is [Int64.sub x Int64.one]. *)
val pred : int64 -> int64

(** Return the absolute value of its argument. *)
val abs : int64 -> int64

(** The greatest representable 64-bit integer, 2{^63} - 1. *)
val max_int : int64

(** The smallest representable 64-bit integer, -2{^63}. *)
val min_int : int64

(** Bitwise logical and. *)
external logand : int64 -> int64 -> int64 = "%int64_and"

(** Bitwise logical or. *)
external logor : int64 -> int64 -> int64 = "%int64_or"

(** Bitwise logical exclusive or. *)
external logxor : int64 -> int64 -> int64 = "%int64_xor"

(** Bitwise logical negation. *)
val lognot : int64 -> int64

(** [Int64.shift_left x y] shifts [x] to the left by [y] bits.
    The result is unspecified if [y < 0] or [y >= 64]. *)
external shift_left : int64 -> int -> int64 = "%int64_lsl"

(** [Int64.shift_right x y] shifts [x] to the right by [y] bits.
    This is an arithmetic shift: the sign bit of [x] is replicated
    and inserted in the vacated bits.
    The result is unspecified if [y < 0] or [y >= 64]. *)
external shift_right : int64 -> int -> int64 = "%int64_asr"

(** [Int64.shift_right_logical x y] shifts [x] to the right by [y] bits.
    This is a logical shift: zeroes are inserted in the vacated bits
    regardless of the sign of [x].
    The result is unspecified if [y < 0] or [y >= 64]. *)
external shift_right_logical : int64 -> int -> int64 = "%int64_lsr"

(** Convert the given integer (type [int]) to a 64-bit integer
    (type [int64]). *)
external of_int : int -> int64 = "%int64_of_int"

(** Convert the given 64-bit integer (type [int64]) to an
    integer (type [int]).  On 64-bit platforms, the 64-bit integer
    is taken modulo 2{^63}, i.e. the high-order bit is lost
    during the conversion.  On 32-bit platforms, the 64-bit integer
    is taken modulo 2{^31}, i.e. the top 33 bits are lost
    during the conversion. *)
external to_int : int64 -> int = "%int64_to_int"

(** Convert the given floating-point number to a 64-bit integer,
    discarding the fractional part (truncate towards 0).
    The result of the conversion is undefined if, after truncation,
    the number is outside the range \[{!Int64.min_int}, {!Int64.max_int}\]. *)
external of_float : float -> int64
  = "caml_int64_of_float" "caml_int64_of_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Convert the given 64-bit integer to a floating-point number. *)
external to_float : int64 -> float
  = "caml_int64_to_float" "caml_int64_to_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Convert the given 32-bit integer (type [int32])
    to a 64-bit integer (type [int64]). *)
external of_int32 : int32 -> int64 = "%int64_of_int32"

(** Convert the given 64-bit integer (type [int64]) to a
    32-bit integer (type [int32]). The 64-bit integer
    is taken modulo 2{^32}, i.e. the top 32 bits are lost
    during the conversion.  *)
external to_int32 : int64 -> int32 = "%int64_to_int32"

(** Convert the given native integer (type [nativeint])
    to a 64-bit integer (type [int64]). *)
external of_nativeint : nativeint -> int64 = "%int64_of_nativeint"

(** Convert the given 64-bit integer (type [int64]) to a
    native integer.  On 32-bit platforms, the 64-bit integer
    is taken modulo 2{^32}.  On 64-bit platforms,
    the conversion is exact. *)
external to_nativeint : int64 -> nativeint = "%int64_to_nativeint"

(** Convert the given string to a 64-bit integer.
    The string is read in decimal (by default, or if the string
    begins with [0u]) or in hexadecimal, octal or binary if the
    string begins with [0x], [0o] or [0b] respectively.

    The [0u] prefix reads the input as an unsigned integer in the range
    [[0, 2*Int64.max_int+1]].  If the input exceeds {!Int64.max_int}
    it is converted to the signed integer
    [Int64.min_int + input - Int64.max_int - 1].

    The [_] (underscore) character can appear anywhere in the string
    and is ignored.
    Raise [Failure "Int64.of_string"] if the given string is not
    a valid representation of an integer, or if the integer represented
    exceeds the range of integers representable in type [int64]. *)
external of_string : string -> int64 = "caml_int64_of_string"

(** Same as [of_string], but return [None] instead of raising.
    @since 4.05 *)
val of_string_opt : string -> int64 option

(** Return the string representation of its argument, in decimal. *)
val to_string : int64 -> string

(** Return the internal representation of the given float according
    to the IEEE 754 floating-point 'double format' bit layout.
    Bit 63 of the result represents the sign of the float;
    bits 62 to 52 represent the (biased) exponent; bits 51 to 0
    represent the mantissa. *)
external bits_of_float : float -> int64
  = "caml_int64_bits_of_float" "caml_int64_bits_of_float_unboxed"
  [@@unboxed] [@@noalloc]

(** Return the floating-point number whose internal representation,
    according to the IEEE 754 floating-point 'double format' bit layout,
    is the given [int64]. *)
external float_of_bits : int64 -> float
  = "caml_int64_float_of_bits" "caml_int64_float_of_bits_unboxed"
  [@@unboxed] [@@noalloc]

(** An alias for the type of 64-bit integers. *)
type t = int64

(** The comparison function for 64-bit integers, with the same specification as
    {!Pervasives.compare}.  Along with the type [t], this function [compare]
    allows the module [Int64] to be passed as argument to the functors
    {!Set.Make} and {!Map.Make}. *)
val compare : t -> t -> int

(** The equal function for int64s.
    @since 4.03.0 *)
val equal : t -> t -> bool
end
module Format : sig
# 1 "../lib_protocol_environment/sigs/v1/format.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Pierre Weis, projet Cristal, INRIA Rocquencourt            *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(* TEZOS CHANGES

   * Import version 4.06.1
   * Remove channel functions
   * Remove toplevel effect based functions
   * Remove deprecated functions
   * Remove redirecting the standard formatter output
   * Remove redefining formatter output and output functions
   * Remove redefining semantic tag operations (too complex and
     imperative for the need of error message generation)
   * Remove defining formatters and symbolic pretty printing
*)

(** Pretty-printing.

    This module implements a pretty-printing facility to format values
    within {{!boxes}'pretty-printing boxes'} and {{!tags}'semantic tags'}
    combined with a set of {{!fpp}printf-like functions}.
    The pretty-printer splits lines at specified {{!breaks}break hints},
    and indents lines according to the box structure.
    Similarly, {{!tags}semantic tags} can be used to decouple text
    presentation from its contents.

    This pretty-printing facility is implemented as an overlay on top of
    abstract {{!section:formatter}formatters} which provide basic output
    functions.
    Some formatters are predefined, notably:
    - {!std_formatter} outputs to {{!Pervasives.stdout}stdout}
    - {!err_formatter} outputs to {{!Pervasives.stderr}stderr}

    Most functions in the {!Format} module come in two variants:
    a short version that operates on {!std_formatter} and the
    generic version prefixed by [pp_] that takes a formatter
    as its first argument.

    More formatters can be created with {!formatter_of_out_channel},
    {!formatter_of_buffer}, {!formatter_of_symbolic_output_buffer}
    or using {{!section:formatter}custom formatters}.

*)

(** {1 Introduction}
    For a gentle introduction to the basics of pretty-printing using
    [Format], read
    {{:http://caml.inria.fr/resources/doc/guides/format.en.html}
    http://caml.inria.fr/resources/doc/guides/format.en.html}.

    You may consider this module as providing an extension to the
    [printf] facility to provide automatic line splitting. The addition of
    pretty-printing annotations to your regular [printf] format strings gives
    you fancy indentation and line breaks.
    Pretty-printing annotations are described below in the documentation of
    the function {!Format.fprintf}.

    You may also use the explicit pretty-printing box management and printing
    functions provided by this module. This style is more basic but more
    verbose than the concise [fprintf] format strings.

    For instance, the sequence
    [open_box 0; print_string "x ="; print_space ();
    print_int 1; close_box (); print_newline ()]
    that prints [x = 1] within a pretty-printing box, can be
    abbreviated as [printf "@[%s@ %i@]@." "x =" 1], or even shorter
    [printf "@[x =@ %i@]@." 1].

    Rule of thumb for casual users of this library:
    - use simple pretty-printing boxes (as obtained by [open_box 0]);
    - use simple break hints as obtained by [print_cut ()] that outputs a
    simple break hint, or by [print_space ()] that outputs a space
    indicating a break hint;
    - once a pretty-printing box is open, display its material with basic
    printing functions (e. g. [print_int] and [print_string]);
    - when the material for a pretty-printing box has been printed, call
    [close_box ()] to close the box;
    - at the end of pretty-printing, flush the pretty-printer to display all
    the remaining material, e.g. evaluate [print_newline ()].

    The behavior of pretty-printing commands is unspecified
    if there is no open pretty-printing box. Each box opened by
    one of the [open_] functions below must be closed using [close_box]
    for proper formatting. Otherwise, some of the material printed in the
    boxes may not be output, or may be formatted incorrectly.

    In case of interactive use, each phrase is executed in the initial state
    of the standard pretty-printer: after each phrase execution, the
    interactive system closes all open pretty-printing boxes, flushes all
    pending text, and resets the standard pretty-printer.

    Warning: mixing calls to pretty-printing functions of this module with
    calls to {!Pervasives} low level output functions is error prone.

    The pretty-printing functions output material that is delayed in the
    pretty-printer queue and stacks in order to compute proper line
    splitting. In contrast, basic I/O output functions write directly in
    their output device. As a consequence, the output of a basic I/O function
    may appear before the output of a pretty-printing function that has been
    called before. For instance,
    [
    Pervasives.print_string "<";
    Format.print_string "PRETTY";
    Pervasives.print_string ">";
    Format.print_string "TEXT";
    ]
    leads to output [<>PRETTYTEXT].

*)

(** Abstract data corresponding to a pretty-printer (also called a
    formatter) and all its machinery. See also {!section:formatter}. *)
type formatter

(** {1:boxes Pretty-printing boxes} *)

(** The pretty-printing engine uses the concepts of pretty-printing box and
    break hint to drive indentation and line splitting behavior of the
    pretty-printer.

    Each different pretty-printing box kind introduces a specific line splitting
    policy:

    - within an {e horizontal} box, break hints never split the line (but the
    line may be split in a box nested deeper),
    - within a {e vertical} box, break hints always split the line,
    - within an {e horizontal/vertical} box, if the box fits on the current line
    then break hints never split the line, otherwise break hint always split
    the line,
    - within a {e compacting} box, a break hint never splits the line,
    unless there is no more room on the current line.

    Note that line splitting policy is box specific: the policy of a box does
    not rule the policy of inner boxes. For instance, if a vertical box is
    nested in an horizontal box, all break hints within the vertical box will
    split the line.
*)

(** [pp_open_box ppf d] opens a new compacting pretty-printing box with
    offset [d] in the formatter [ppf].

    Within this box, the pretty-printer prints as much as possible material on
    every line.

    A break hint splits the line if there is no more room on the line to
    print the remainder of the box.

    Within this box, the pretty-printer emphasizes the box structure: a break
    hint also splits the line if the splitting ``moves to the left''
    (i.e. the new line gets an indentation smaller than the one of the current
    line).

    This box is the general purpose pretty-printing box.

    If the pretty-printer splits the line in the box, offset [d] is added to
    the current indentation.
*)
val pp_open_box : formatter -> int -> unit

(** Closes the most recently open pretty-printing box. *)
val pp_close_box : formatter -> unit -> unit

(** [pp_open_hbox ppf ()] opens a new 'horizontal' pretty-printing box.

    This box prints material on a single line.

    Break hints in a horizontal box never split the line.
    (Line splitting may still occur inside boxes nested deeper).
*)
val pp_open_hbox : formatter -> unit -> unit

(** [pp_open_vbox ppf d] opens a new 'vertical' pretty-printing box
    with offset [d].

    This box prints material on as many lines as break hints in the box.

    Every break hint in a vertical box splits the line.

    If the pretty-printer splits the line in the box, [d] is added to the
    current indentation.
*)
val pp_open_vbox : formatter -> int -> unit

(** [pp_open_hvbox ppf d] opens a new 'horizontal/vertical' pretty-printing box
    with offset [d].

    This box behaves as an horizontal box if it fits on a single line,
    otherwise it behaves as a vertical box.

    If the pretty-printer splits the line in the box, [d] is added to the
    current indentation.
*)
val pp_open_hvbox : formatter -> int -> unit

(** [pp_open_hovbox ppf d] opens a new 'horizontal-or-vertical'
    pretty-printing box with offset [d].

    This box prints material as much as possible on every line.

    A break hint splits the line if there is no more room on the line to
    print the remainder of the box.

    If the pretty-printer splits the line in the box, [d] is added to the
    current indentation.
*)
val pp_open_hovbox : formatter -> int -> unit

(** {1 Formatting functions} *)

(** [pp_print_string ppf s] prints [s] in the current pretty-printing box. *)
val pp_print_string : formatter -> string -> unit

(** [pp_print_as ppf len s] prints [s] in the current pretty-printing box.
    The pretty-printer formats [s] as if it were of length [len].
*)
val pp_print_as : formatter -> int -> string -> unit

(** Print an integer in the current pretty-printing box. *)
val pp_print_int : formatter -> int -> unit

(** Print a floating point number in the current pretty-printing box. *)
val pp_print_float : formatter -> float -> unit

(** Print a character in the current pretty-printing box. *)
val pp_print_char : formatter -> char -> unit

(** Print a boolean in the current pretty-printing box. *)
val pp_print_bool : formatter -> bool -> unit

(** {1:breaks Break hints} *)

(** A 'break hint' tells the pretty-printer to output some space or split the
    line whichever way is more appropriate to the current pretty-printing box
    splitting rules.

    Break hints are used to separate printing items and are mandatory to let
    the pretty-printer correctly split lines and indent items.

    Simple break hints are:
    - the 'space': output a space or split the line if appropriate,
    - the 'cut': split the line if appropriate.

    Note: the notions of space and line splitting are abstract for the
    pretty-printing engine, since those notions can be completely redefined
    by the programmer.
    However, in the pretty-printer default setting, ``output a space'' simply
    means printing a space character (ASCII code 32) and ``split the line''
    means printing a newline character (ASCII code 10).
*)

(** [pp_print_space ppf ()] emits a 'space' break hint:
    the pretty-printer may split the line at this point,
    otherwise it prints one space.

    [pp_print_space ppf ()] is equivalent to [pp_print_break ppf 1 0].
*)
val pp_print_space : formatter -> unit -> unit

(** [pp_print_cut ppf ()] emits a 'cut' break hint:
    the pretty-printer may split the line at this point,
    otherwise it prints nothing.

    [pp_print_cut ppf ()] is equivalent to [pp_print_break ppf 0 0].
*)
val pp_print_cut : formatter -> unit -> unit

(** [pp_print_break ppf nspaces offset] emits a 'full' break hint:
    the pretty-printer may split the line at this point,
    otherwise it prints [nspaces] spaces.

    If the pretty-printer splits the line, [offset] is added to
    the current indentation.
*)
val pp_print_break : formatter -> int -> int -> unit

(** Force a new line in the current pretty-printing box.

    The pretty-printer must split the line at this point,

    Not the normal way of pretty-printing, since imperative line splitting may
    interfere with current line counters and box size calculation.
    Using break hints within an enclosing vertical box is a better
    alternative.
*)
val pp_force_newline : formatter -> unit -> unit

(** Execute the next formatting command if the preceding line
    has just been split. Otherwise, ignore the next formatting
    command.
*)
val pp_print_if_newline : formatter -> unit -> unit

(** {1 Pretty-printing termination} *)

(** End of pretty-printing: resets the pretty-printer to initial state.

    All open pretty-printing boxes are closed, all pending text is printed.
    In addition, the pretty-printer low level output device is flushed to
    ensure that all pending text is really displayed.

    Note: never use [print_flush] in the normal course of a pretty-printing
    routine, since the pretty-printer uses a complex buffering machinery to
    properly indent the output; manually flushing those buffers at random
    would conflict with the pretty-printer strategy and result to poor
    rendering.

    Only consider using [print_flush] when displaying all pending material is
    mandatory (for instance in case of interactive use when you want the user
    to read some text) and when resetting the pretty-printer state will not
    disturb further pretty-printing.

    Warning: If the output device of the pretty-printer is an output channel,
    repeated calls to [print_flush] means repeated calls to {!Pervasives.flush}
    to flush the out channel; these explicit flush calls could foil the
    buffering strategy of output channels and could dramatically impact
    efficiency.
*)
val pp_print_flush : formatter -> unit -> unit

(** End of pretty-printing: resets the pretty-printer to initial state.

    All open pretty-printing boxes are closed, all pending text is printed.

    Equivalent to {!print_flush} followed by a new line.
    See corresponding words of caution for {!print_flush}.

    Note: this is not the normal way to output a new line;
    the preferred method is using break hints within a vertical pretty-printing
    box.
*)
val pp_print_newline : formatter -> unit -> unit

(** {1 Margin} *)

(** [pp_set_margin ppf d] sets the right margin to [d] (in characters):
    the pretty-printer splits lines that overflow the right margin according to
    the break hints given.
    Nothing happens if [d] is smaller than 2.
    If [d] is too large, the right margin is set to the maximum
    admissible value (which is greater than [10 ^ 9]).
    If [d] is less than the current maximum indentation limit, the
    maximum indentation limit is decreased while trying to preserve
    a minimal ratio [max_indent/margin>=50%] and if possible
    the current difference [margin - max_indent].
*)
val pp_set_margin : formatter -> int -> unit

(** Returns the position of the right margin. *)
val pp_get_margin : formatter -> unit -> int

(** {1 Maximum indentation limit} *)

(** [pp_set_max_indent ppf d] sets the maximum indentation limit of lines
    to [d] (in characters):
    once this limit is reached, new pretty-printing boxes are rejected to the
    left, if they do not fit on the current line.

    Nothing happens if [d] is smaller than 2.
    If [d] is too large, the limit is set to the maximum
    admissible value (which is greater than [10 ^ 9]).

    If [d] is greater or equal than the current margin, it is ignored,
    and the current maximum indentation limit is kept.
*)
val pp_set_max_indent : formatter -> int -> unit

(** Return the maximum indentation limit (in characters). *)
val pp_get_max_indent : formatter -> unit -> int

(** {1 Maximum formatting depth} *)

(** The maximum formatting depth is the maximum number of pretty-printing
    boxes simultaneously open.

    Material inside boxes nested deeper is printed as an ellipsis (more
    precisely as the text returned by {!get_ellipsis_text} [()]).
*)

(** [pp_set_max_boxes ppf max] sets the maximum number of pretty-printing
    boxes simultaneously open.

    Material inside boxes nested deeper is printed as an ellipsis (more
    precisely as the text returned by {!get_ellipsis_text} [()]).

    Nothing happens if [max] is smaller than 2.
*)
val pp_set_max_boxes : formatter -> int -> unit

(** Returns the maximum number of pretty-printing boxes allowed before
    ellipsis.
*)
val pp_get_max_boxes : formatter -> unit -> int

(** Tests if the maximum number of pretty-printing boxes allowed have already
    been opened.
*)
val pp_over_max_boxes : formatter -> unit -> bool

(** {1 Tabulation boxes} *)

(**

   A {e tabulation box} prints material on lines divided into cells of fixed
   length. A tabulation box provides a simple way to display vertical columns
   of left adjusted text.

   This box features command [set_tab] to define cell boundaries, and command
   [print_tab] to move from cell to cell and split the line when there is no
   more cells to print on the line.

   Note: printing within tabulation box is line directed, so arbitrary line
   splitting inside a tabulation box leads to poor rendering. Yet, controlled
   use of tabulation boxes allows simple printing of columns within
   module {!Format}.
*)

(** [open_tbox ()] opens a new tabulation box.

    This box prints lines separated into cells of fixed width.

    Inside a tabulation box, special {e tabulation markers} defines points of
    interest on the line (for instance to delimit cell boundaries).
    Function {!Format.set_tab} sets a tabulation marker at insertion point.

    A tabulation box features specific {e tabulation breaks} to move to next
    tabulation marker or split the line. Function {!Format.print_tbreak} prints
    a tabulation break.
*)
val pp_open_tbox : formatter -> unit -> unit

(** Closes the most recently opened tabulation box. *)
val pp_close_tbox : formatter -> unit -> unit

(** Sets a tabulation marker at current insertion point. *)
val pp_set_tab : formatter -> unit -> unit

(** [print_tab ()] emits a 'next' tabulation break hint: if not already set on
    a tabulation marker, the insertion point moves to the first tabulation
    marker on the right, or the pretty-printer splits the line and insertion
    point moves to the leftmost tabulation marker.

    It is equivalent to [print_tbreak 0 0]. *)
val pp_print_tab : formatter -> unit -> unit

(** [print_tbreak nspaces offset] emits a 'full' tabulation break hint.

    If not already set on a tabulation marker, the insertion point moves to the
    first tabulation marker on the right and the pretty-printer prints
    [nspaces] spaces.

    If there is no next tabulation marker on the right, the pretty-printer
    splits the line at this point, then insertion point moves to the leftmost
    tabulation marker of the box.

    If the pretty-printer splits the line, [offset] is added to
    the current indentation.
*)
val pp_print_tbreak : formatter -> int -> int -> unit

(** {1 Ellipsis} *)

(** Set the text of the ellipsis printed when too many pretty-printing boxes
    are open (a single dot, [.], by default).
*)
val pp_set_ellipsis_text : formatter -> string -> unit

(** Return the text of the ellipsis. *)
val pp_get_ellipsis_text : formatter -> unit -> string

(** {1:tags Semantic tags} *)

type tag = string

(** {i Semantic tags} (or simply {e tags}) are user's defined delimiters
    to associate user's specific operations to printed entities.

    Common usage of semantic tags is text decoration to get specific font or
    text size rendering for a display device, or marking delimitation of
    entities (e.g. HTML or TeX elements or terminal escape sequences).
    More sophisticated usage of semantic tags could handle dynamic
    modification of the pretty-printer behavior to properly print the material
    within some specific tags.

    In order to properly delimit printed entities, a semantic tag must be
    opened before and closed after the entity. Semantic tags must be properly
    nested like parentheses.

    Tag specific operations occur any time a tag is opened or closed, At each
    occurrence, two kinds of operations are performed {e tag-marking} and
    {e tag-printing}:
    - The tag-marking operation is the simpler tag specific operation: it simply
    writes a tag specific string into the output device of the
    formatter. Tag-marking does not interfere with line-splitting computation.
    - The tag-printing operation is the more involved tag specific operation: it
    can print arbitrary material to the formatter. Tag-printing is tightly
    linked to the current pretty-printer operations.

    Roughly speaking, tag-marking is commonly used to get a better rendering of
    texts in the rendering device, while tag-printing allows fine tuning of
    printing routines to print the same entity differently according to the
    semantic tags (i.e. print additional material or even omit parts of the
    output).

    More precisely: when a semantic tag is opened or closed then both and
    successive 'tag-printing' and 'tag-marking' operations occur:
    - Tag-printing a semantic tag means calling the formatter specific function
    [print_open_tag] (resp. [print_close_tag]) with the name of the tag as
    argument: that tag-printing function can then print any regular material
    to the formatter (so that this material is enqueued as usual in the
    formatter queue for further line splitting computation).
    - Tag-marking a semantic tag means calling the formatter specific function
    [mark_open_tag] (resp. [mark_close_tag]) with the name of the tag as
    argument: that tag-marking function can then return the 'tag-opening
    marker' (resp. `tag-closing marker') for direct output into the output
    device of the formatter.

    Being written directly into the output device of the formatter, semantic
    tag marker strings are not considered as part of the printing material that
    drives line splitting (in other words, the length of the strings
    corresponding to tag markers is considered as zero for line splitting).

    Thus, semantic tag handling is in some sense transparent to pretty-printing
    and does not interfere with usual indentation. Hence, a single
    pretty-printing routine can output both simple 'verbatim' material or
    richer decorated output depending on the treatment of tags. By default,
    tags are not active, hence the output is not decorated with tag
    information. Once [set_tags] is set to [true], the pretty-printer engine
    honors tags and decorates the output accordingly.

    Default tag-marking functions behave the HTML way: tags are enclosed in "<"
    and ">"; hence, opening marker for tag [t] is ["<t>"] and closing marker is
    ["</t>"].

    Default tag-printing functions just do nothing.

    Tag-marking and tag-printing functions are user definable and can
    be set by calling {!set_formatter_tag_functions}.

    Semantic tag operations may be set on or off with {!set_tags}.
    Tag-marking operations may be set on or off with {!set_mark_tags}.
    Tag-printing operations may be set on or off with {!set_print_tags}.
*)

(** [pp_open_tag ppf t] opens the semantic tag named [t].

    The [print_open_tag] tag-printing function of the formatter is called with
    [t] as argument; then the opening tag marker for [t], as given by
    [mark_open_tag t], is written into the output device of the formatter.
*)
val pp_open_tag : formatter -> string -> unit

(** [pp_close_tag ppf ()] closes the most recently opened semantic tag [t].

    The closing tag marker, as given by [mark_close_tag t], is written into the
    output device of the formatter; then the [print_close_tag] tag-printing
    function of the formatter is called with [t] as argument.
*)
val pp_close_tag : formatter -> unit -> unit

(** [pp_set_tags ppf b] turns on or off the treatment of semantic tags
    (default is off).
*)
val pp_set_tags : formatter -> bool -> unit

(** [pp_set_print_tags ppf b] turns on or off the tag-printing operations. *)
val pp_set_print_tags : formatter -> bool -> unit

(** [pp_set_mark_tags ppf b] turns on or off the tag-marking operations. *)
val pp_set_mark_tags : formatter -> bool -> unit

(** Return the current status of tag-printing operations. *)
val pp_get_print_tags : formatter -> unit -> bool

(** Return the current status of tag-marking operations. *)
val pp_get_mark_tags : formatter -> unit -> bool

(** {1 Convenience formatting functions.} *)

(** [pp_print_list ?pp_sep pp_v ppf l] prints items of list [l],
    using [pp_v] to print each item, and calling [pp_sep]
    between items ([pp_sep] defaults to {!pp_print_cut}.
    Does nothing on empty lists.

    @since 4.02.0
*)
val pp_print_list :
  ?pp_sep:(formatter -> unit -> unit) ->
  (formatter -> 'a -> unit) ->
  formatter ->
  'a list ->
  unit

(** [pp_print_text ppf s] prints [s] with spaces and newlines respectively
    printed using {!pp_print_space} and {!pp_force_newline}.

    @since 4.02.0
*)
val pp_print_text : formatter -> string -> unit

(** {1:fpp Formatted pretty-printing} *)

(**
   Module [Format] provides a complete set of [printf] like functions for
   pretty-printing using format string specifications.

   Specific annotations may be added in the format strings to give
   pretty-printing commands to the pretty-printing engine.

   Those annotations are introduced in the format strings using the [@]
   character. For instance, [@ ] means a space break, [@,] means a cut,
   [@\[] opens a new box, and [@\]] closes the last open box.

*)

val fprintf : formatter -> ('a, formatter, unit) format -> 'a

(** [fprintf ff fmt arg1 ... argN] formats the arguments [arg1] to [argN]
    according to the format string [fmt], and outputs the resulting string on
    the formatter [ff].

    The format string [fmt] is a character string which contains three types of
    objects: plain characters and conversion specifications as specified in
    the {!Printf} module, and pretty-printing indications specific to the
    [Format] module.

    The pretty-printing indication characters are introduced by
    a [@] character, and their meanings are:
    - [@\[]: open a pretty-printing box. The type and offset of the
    box may be optionally specified with the following syntax:
    the [<] character, followed by an optional box type indication,
    then an optional integer offset, and the closing [>] character.
    Pretty-printing box type is one of [h], [v], [hv], [b], or [hov].
    '[h]' stands for an 'horizontal' pretty-printing box,
    '[v]' stands for a 'vertical' pretty-printing box,
    '[hv]' stands for an 'horizontal/vertical' pretty-printing box,
    '[b]' stands for an 'horizontal-or-vertical' pretty-printing box
    demonstrating indentation,
    '[hov]' stands a simple 'horizontal-or-vertical' pretty-printing box.
    For instance, [@\[<hov 2>] opens an 'horizontal-or-vertical'
    pretty-printing box with indentation 2 as obtained with [open_hovbox 2].
    For more details about pretty-printing boxes, see the various box opening
    functions [open_*box].
    - [@\]]: close the most recently opened pretty-printing box.
    - [@,]: output a 'cut' break hint, as with [print_cut ()].
    - [@ ]: output a 'space' break hint, as with [print_space ()].
    - [@;]: output a 'full' break hint as with [print_break]. The
    [nspaces] and [offset] parameters of the break hint may be
    optionally specified with the following syntax:
    the [<] character, followed by an integer [nspaces] value,
    then an integer [offset], and a closing [>] character.
    If no parameters are provided, the good break defaults to a
    'space' break hint.
    - [@.]: flush the pretty-printer and split the line, as with
    [print_newline ()].
    - [@<n>]: print the following item as if it were of length [n].
    Hence, [printf "@<0>%s" arg] prints [arg] as a zero length string.
    If [@<n>] is not followed by a conversion specification,
    then the following character of the format is printed as if
    it were of length [n].
    - [@\{]: open a semantic tag. The name of the tag may be optionally
    specified with the following syntax:
    the [<] character, followed by an optional string
    specification, and the closing [>] character. The string
    specification is any character string that does not contain the
    closing character ['>']. If omitted, the tag name defaults to the
    empty string.
    For more details about semantic tags, see the functions {!open_tag} and
    {!close_tag}.
    - [@\}]: close the most recently opened semantic tag.
    - [@?]: flush the pretty-printer as with [print_flush ()].
    This is equivalent to the conversion [%!].
    - [@\n]: force a newline, as with [force_newline ()], not the normal way
    of pretty-printing, you should prefer using break hints inside a vertical
    pretty-printing box.

    Note: To prevent the interpretation of a [@] character as a
    pretty-printing indication, escape it with a [%] character.
    Old quotation mode [@@] is deprecated since it is not compatible with
    formatted input interpretation of character ['@'].

    Example: [printf "@[%s@ %d@]@." "x =" 1] is equivalent to
    [open_box (); print_string "x ="; print_space ();
    print_int 1; close_box (); print_newline ()].
    It prints [x = 1] within a pretty-printing 'horizontal-or-vertical' box.

*)

(** Same as [printf] above, but instead of printing on a formatter,
    returns a string containing the result of formatting the arguments.
    Note that the pretty-printer queue is flushed at the end of {e each
    call} to [sprintf].

    In case of multiple and related calls to [sprintf] to output
    material on a single string, you should consider using [fprintf]
    with the predefined formatter [str_formatter] and call
    [flush_str_formatter ()] to get the final result.

    Alternatively, you can use [Format.fprintf] with a formatter writing to a
    buffer of your own: flushing the formatter and the buffer at the end of
    pretty-printing returns the desired string.
*)
val sprintf : ('a, unit, string) format -> 'a

(** Same as [printf] above, but instead of printing on a formatter,
    returns a string containing the result of formatting the arguments.
    The type of [asprintf] is general enough to interact nicely with [%a]
    conversions.

    @since 4.01.0
*)
val asprintf : ('a, formatter, unit, string) format4 -> 'a

(** Same as [fprintf] above, but does not print anything.
    Useful to ignore some material when conditionally printing.

    @since 3.10.0
*)
val ifprintf : formatter -> ('a, formatter, unit) format -> 'a

(** Formatted Pretty-Printing with continuations. *)

(** Same as [fprintf] above, but instead of returning immediately,
    passes the formatter to its first argument at the end of printing. *)
val kfprintf :
  (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) format4 -> 'b

(** Same as [kfprintf] above, but does not print anything.
    Useful to ignore some material when conditionally printing.

    @since 3.12.0
*)
val ikfprintf :
  (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) format4 -> 'b

(** Same as [sprintf] above, but instead of returning the string,
    passes it to the first argument. *)
val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b

(** Same as [asprintf] above, but instead of returning the string,
    passes it to the first argument.

    @since 4.03
*)
val kasprintf : (string -> 'a) -> ('b, formatter, unit, 'a) format4 -> 'b
end
module MBytes : sig
# 1 "../lib_protocol_environment/sigs/v1/mBytes.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type t

val create : int -> t

val length : t -> int

val copy : t -> t

(** [sub src ofs len] extract a sub-array of [src] starting at [ofs]
    and of length [len]. No copying of elements is involved: the
    sub-array and the original array share the same storage space. *)
val sub : t -> int -> int -> t

(** [blit src ofs_src dst ofs_dst len] copy [len] bytes from [src]
    starting at [ofs_src] into [dst] starting at [ofs_dst]. *)
val blit : t -> int -> t -> int -> int -> unit

(** See [blit] *)
val blit_of_string : string -> int -> t -> int -> int -> unit

(** See [blit] *)
val blit_to_bytes : t -> int -> bytes -> int -> int -> unit

(** [of_string s] create an byte array filled with the same content than [s]. *)
val of_string : string -> t

(** [to_string b] dump the array content in a [string]. *)
val to_string : t -> string

(** [sub_string b ofs len] is equivalent to [to_string (sub b ofs len)]. *)
val sub_string : t -> int -> int -> string

(** Functions reading and writing bytes  *)

(** [get_char buff i] reads 1 byte at offset i as a char *)
val get_char : t -> int -> char

(** [get_uint8 buff i] reads 1 byte at offset i as an unsigned int of 8
    bits. i.e. It returns a value between 0 and 2^8-1 *)
val get_uint8 : t -> int -> int

(** [get_int8 buff i] reads 1 byte at offset i as a signed int of 8
    bits. i.e. It returns a value between -2^7 and 2^7-1 *)
val get_int8 : t -> int -> int

(** [set_char buff i v] writes [v] to [buff] at offset [i] *)
val set_char : t -> int -> char -> unit

(** [set_int8 buff i v] writes the least significant 8 bits of [v]
    to [buff] at offset [i] *)
val set_int8 : t -> int -> int -> unit

(** Functions reading according to Big Endian byte order *)

(** [get_uint16 buff i] reads 2 bytes at offset i as an unsigned int
      of 16 bits. i.e. It returns a value between 0 and 2^16-1 *)
val get_uint16 : t -> int -> int

(** [get_int16 buff i] reads 2 byte at offset i as a signed int of
      16 bits. i.e. It returns a value between -2^15 and 2^15-1 *)
val get_int16 : t -> int -> int

(** [get_int32 buff i] reads 4 bytes at offset i as an int32. *)
val get_int32 : t -> int -> int32

(** [get_int64 buff i] reads 8 bytes at offset i as an int64. *)
val get_int64 : t -> int -> int64

(** [set_int16 buff i v] writes the least significant 16 bits of [v]
      to [buff] at offset [i] *)
val set_int16 : t -> int -> int -> unit

(** [set_int32 buff i v] writes [v] to [buff] at offset [i] *)
val set_int32 : t -> int -> int32 -> unit

(** [set_int64 buff i v] writes [v] to [buff] at offset [i] *)
val set_int64 : t -> int -> int64 -> unit

module LE : sig
  (** Functions reading according to Little Endian byte order *)

  (** [get_uint16 buff i] reads 2 bytes at offset i as an unsigned int
      of 16 bits. i.e. It returns a value between 0 and 2^16-1 *)
  val get_uint16 : t -> int -> int

  (** [get_int16 buff i] reads 2 byte at offset i as a signed int of
      16 bits. i.e. It returns a value between -2^15 and 2^15-1 *)
  val get_int16 : t -> int -> int

  (** [get_int32 buff i] reads 4 bytes at offset i as an int32. *)
  val get_int32 : t -> int -> int32

  (** [get_int64 buff i] reads 8 bytes at offset i as an int64. *)
  val get_int64 : t -> int -> int64

  (** [set_int16 buff i v] writes the least significant 16 bits of [v]
      to [buff] at offset [i] *)
  val set_int16 : t -> int -> int -> unit

  (** [set_int32 buff i v] writes [v] to [buff] at offset [i] *)
  val set_int32 : t -> int -> int32 -> unit

  (** [set_int64 buff i v] writes [v] to [buff] at offset [i] *)
  val set_int64 : t -> int -> int64 -> unit
end

val ( = ) : t -> t -> bool

val ( <> ) : t -> t -> bool

val ( < ) : t -> t -> bool

val ( <= ) : t -> t -> bool

val ( >= ) : t -> t -> bool

val ( > ) : t -> t -> bool

val compare : t -> t -> int

val concat : string -> t list -> t

type hex = [`Hex of string]

val to_hex : t -> hex

val of_hex : hex -> t
end
module Z : sig
# 1 "../lib_protocol_environment/sigs/v1/z.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos Protocol Environment - Arbitrary precision arithmetic. *)

type t

val zero : t

val one : t

(** Returns its argument plus one. *)
val succ : t -> t

(** Absolute value. *)
val abs : t -> t

(** Unary negation. *)
val neg : t -> t

(** Addition. *)
val add : t -> t -> t

(** Subtraction. *)
val sub : t -> t -> t

(** Multiplication. *)
val mul : t -> t -> t

(** Euclidean division and remainder.  [ediv_rem a b] returns a pair [(q, r)]
    such that [a = b * q + r] and [0 <= r < |b|].
    Raises [Division_by_zero] if [b = 0].
*)
val ediv_rem : t -> t -> t * t

(** Bitwise logical and. *)
val logand : t -> t -> t

(** Bitwise logical or. *)
val logor : t -> t -> t

(** Bitwise logical exclusive or. *)
val logxor : t -> t -> t

(** Bitwise logical negation.
    The identity [lognot a]=[-a-1] always hold.
*)
val lognot : t -> t

(** Shifts to the left.
    Equivalent to a multiplication by a power of 2.
    The second argument must be non-negative.
*)
val shift_left : t -> int -> t

(** Shifts to the right.
    This is an arithmetic shift,
    equivalent to a division by a power of 2 with rounding towards -oo.
    The second argument must be non-negative.
*)
val shift_right : t -> int -> t

(** Gives a human-readable, decimal string representation of the argument. *)
val to_string : t -> string

(** Converts a string to an integer.
    An optional [-] prefix indicates a negative number, while a [+]
    prefix is ignored.
    An optional prefix [0x], [0o], or [0b] (following the optional [-]
    or [+] prefix) indicates that the number is,
    represented, in hexadecimal, octal, or binary, respectively.
    Otherwise, base 10 is assumed.
    (Unlike C, a lone [0] prefix does not denote octal.)
    Raises an [Invalid_argument] exception if the string is not a
    syntactically correct representation of an integer.
*)
val of_string : string -> t

(** Converts to a 64-bit integer. May raise [Overflow]. *)
val to_int64 : t -> int64

(** Converts from a 64-bit integer. *)
val of_int64 : int64 -> t

(** Converts to a base integer. May raise an [Overflow]. *)
val to_int : t -> int

(** Converts from a base integer. *)
val of_int : int -> t

val to_bits : ?pad_to:int -> t -> MBytes.t

val of_bits : MBytes.t -> t

val equal : t -> t -> bool

val compare : t -> t -> int

(** Returns the number of significant bits in the given number.
    If [x] is zero, [numbits x] returns 0.  Otherwise,
    [numbits x] returns a positive integer [n] such that
    [2^{n-1} <= |x| < 2^n].  Note that [numbits] is defined
    for negative arguments, and that [numbits (-x) = numbits x]. *)
val numbits : t -> int
end
module Lwt : sig
# 1 "../lib_protocol_environment/sigs/v1/lwt.mli"
(* Lightweight thread library for OCaml
 * http://www.ocsigen.org/lwt
 * Interface Lwt
 * Copyright (C) 2005-2008 J�r�me Vouillon
 * Laboratoire PPS - CNRS Universit� Paris Diderot
 *               2009-2012 J�r�mie Dimino
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, with linking exceptions;
 * either version 2.1 of the License, or (at your option) any later
 * version. See COPYING file for details.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *)

(* TEZOS CHANGES

   * import version 2.4.5
   * Comment a few function that shouldn't be used in the protocol:
     * choose: scheduling may be system dependent.
     * wait/wakeup
     * state
     * cancel
     * pause
     * async
     * thread storage
     * lwt exceptions
*)

(** Module [Lwt]: cooperative light-weight threads. *)

(** This module defines {e cooperative light-weight threads} with
    their primitives. A {e light-weight thread} represent a
    computation that may be not terminated, for example because it is
    waiting for some event to happen.

    Lwt threads are cooperative in the sense that switching to another
    thread is awlays explicit (with {!wakeup} or {!wakeup_exn}). When a
    thread is running, it executes as much as possible, and then
    returns (a value or an eror) or sleeps.

    Note that inside a Lwt thread, exceptions must be raised with
    {!fail} instead of [raise]. Also the [try ... with ...]
    construction will not catch Lwt errors. You must use {!catch}
    instead. You can also use {!wrap} for functions that may raise
    normal exception.

    Lwt also provides the syntax extension {!Pa_lwt} to make code
    using Lwt more readable.
*)

(** {2 Definitions and basics} *)

(** The type of threads returning a result of type ['a]. *)
type +'a t

(** [return e] is a thread whose return value is the value of the
    expression [e]. *)
val return : 'a -> 'a t

(* val fail : exn -> 'a t *)
(*   (\** [fail e] is a thread that fails with the exception [e]. *\) *)

(** [bind t f] is a thread which first waits for the thread [t] to
    terminate and then, if the thread succeeds, behaves as the
    application of function [f] to the return value of [t].  If the
    thread [t] fails, [bind t f] also fails, with the same
    exception.

    The expression [bind t (fun x -> t')] can intuitively be read as
    [let x = t in t'], and if you use the {e lwt.syntax} syntax
    extension, you can write a bind operation like that: [lwt x = t in t'].

    Note that [bind] is also often used just for synchronization
    purpose: [t'] will not execute before [t] is terminated.

    The result of a thread can be bound several time. *)
val bind : 'a t -> ('a -> 'b t) -> 'b t

(** [t >>= f] is an alternative notation for [bind t f]. *)
val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t

(** [f =<< t] is [t >>= f] *)
val ( =<< ) : ('a -> 'b t) -> 'a t -> 'b t

(** [map f m] map the result of a thread. This is the same as [bind
    m (fun x -> return (f x))] *)
val map : ('a -> 'b) -> 'a t -> 'b t

(** [m >|= f] is [map f m] *)
val ( >|= ) : 'a t -> ('a -> 'b) -> 'b t

(** [f =|< m] is [map f m] *)
val ( =|< ) : ('a -> 'b) -> 'a t -> 'b t

(** {3 Pre-allocated threads} *)

(** [return_unit = return ()] *)
val return_unit : unit t

(** [return_none = return None] *)
val return_none : 'a option t

(** [return_nil = return \[\]] *)
val return_nil : 'a list t

(** [return_true = return true] *)
val return_true : bool t

(** [return_false = return false] *)
val return_false : bool t

(* (\** {2 Thread storage} *\) *)

(* type 'a key *)
(*   (\** Type of a key. Keys are used to store local values into *)
(*       threads *\) *)

(* val new_key : unit -> 'a key *)
(*   (\** [new_key ()] creates a new key. *\) *)

(* val get : 'a key -> 'a option *)
(*   (\** [get key] returns the value associated with [key] in the current *)
(*       thread. *\) *)

(* val with_value : 'a key -> 'a option -> (unit -> 'b) -> 'b *)
(*   (\** [with_value key value f] executes [f] with [value] associated to *)
(*       [key]. The previous value associated to [key] is restored after *)
(*       [f] terminates. *\) *)

(* (\** {2 Exceptions handling} *\) *)

(* val catch : (unit -> 'a t) -> (exn -> 'a t) -> 'a t *)
(*   (\** [catch t f] is a thread that behaves as the thread [t ()] if *)
(*       this thread succeeds.  If the thread [t ()] fails with some *)
(*       exception, [catch t f] behaves as the application of [f] to this *)
(*       exception. *\) *)

(* val try_bind : (unit -> 'a t) -> ('a -> 'b t) -> (exn -> 'b t) -> 'b t *)
(*   (\** [try_bind t f g] behaves as [bind (t ()) f] if [t] does not *)
(*       fail.  Otherwise, it behaves as the application of [g] to the *)
(*       exception associated to [t ()]. *\) *)

(* val finalize : (unit -> 'a t) -> (unit -> unit t) -> 'a t *)
(*   (\** [finalize f g] returns the same result as [f ()] whether it *)
(*       fails or not. In both cases, [g ()] is executed after [f]. *\) *)

(* val wrap : (unit -> 'a) -> 'a t *)
(*   (\** [wrap f] calls [f] and transform the result into a monad. If [f] *)
(*       raise an exception, it is catched by Lwt. *)

(*       This is actually the same as: *)

(*       {[ *)
(*         try *)
(*           return (f ()) *)
(*         with exn -> *)
(*           fail exn *)
(*       ]} *)
(*   *\) *)

(* val wrap1 : ('a -> 'b) -> 'a -> 'b t *)
(*   (\** [wrap1 f x] applies [f] on [x] and returns the result as a *)
(*       thread. If the application of [f] to [x] raise an exception it *)
(*       is catched and a thread is returned. *)

(*       Note that you must use {!wrap} instead of {!wrap1} if the *)
(*       evaluation of [x] may raise an exception. *)

(*       for example the following code is not ok: *)

(*       {[ *)
(*         wrap1 f (Hashtbl.find table key) *)
(*       ]} *)

(*       you should write instead: *)

(*       {[ *)
(*         wrap (fun () -> f (Hashtbl.find table key)) *)
(*       ]} *)
(*   *\) *)

(* val wrap2 : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c t *)
(* val wrap3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd t *)
(* val wrap4 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e t *)
(* val wrap5 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'a -> 'b -> 'c -> 'd -> 'e -> 'f t *)
(* val wrap6 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) -> 'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g t *)
(* val wrap7 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h) -> 'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h t *)

(** {2 Multi-threads composition} *)

(* we shouldn't use choose: the scheduling may be system dependent *)

(* val choose : 'a t list -> 'a t *)
(*   (\** [choose l] behaves as the first thread in [l] to terminate.  If *)
(*       several threads are already terminated, one is choosen at *)
(*       random. *)

(*       Note: {!choose} leaves the local values of the current thread *)
(*       unchanged. *\) *)

(* val nchoose : 'a t list -> 'a list t *)
(*   (\** [nchoose l] returns the value of all that have succcessfully *)
(*       terminated. If all threads are sleeping, it waits for at least *)
(*       one to terminates. If one the threads of [l] fails, [nchoose] *)
(*       fails with the same exception. *)

(*       Note: {!nchoose} leaves the local values of the current thread *)
(*       unchanged. *\) *)

(* val nchoose_split : 'a t list -> ('a list * 'a t list) t *)
(*   (\** [nchoose_split l] does the same as {!nchoose} but also retrurns *)
(*       the list of threads that have not yet terminated. *\) *)

(** [join l] waits for all threads in [l] to terminate. If one of
    the threads fails, then [join l] will fails with the same
    exception as the first one to terminate.

    Note: {!join} leaves the local values of the current thread
    unchanged. *)
val join : unit t list -> unit t

(* val ( <?> ) : 'a t -> 'a t -> 'a t *)
(*   (\** [t <?> t'] is the same as [choose [t; t']] *\) *)

(** [t <&> t'] is the same as [join [t; t']] *)
val ( <&> ) : unit t -> unit t -> unit t

(* val async : (unit -> 'a t) -> unit *)
(*   (\** [async f] starts a thread without waiting for the result. If it *)
(*       fails (now or later), the exception is given to *)
(*       {!async_exception_hook}. *)

(*       You should use this function if you want to start a thread that *)
(*       might fail and don't care what its return value is, nor when it *)
(*       terminates (for instance, because it is looping). *\) *)

(* val ignore_result : 'a t -> unit *)
(*   (\** [ignore_result t] is like [Pervasives.ignore t] except that: *)

(*       - if [t] already failed, it raises the exception now, *)
(*       - if [t] is sleeping and fails later, the exception will be *)
(*         given to {!async_exception_hook}. *\) *)

(* val async_exception_hook : (exn -> unit) ref *)
(*   (\** Function called when a asynchronous exception is thrown. *)

(*       The default behavior is to print an error message with a *)
(*       backtrace if available and to exit the program. *)

(*       The behavior is undefined if this function raise an *)
(*       exception. *\) *)

(* (\** {2 Sleeping and resuming} *\) *)

(* type 'a u *)
(*   (\** The type of thread wakeners. *\) *)

(* val wait : unit -> 'a t * 'a u *)
(*   (\** [wait ()] is a pair of a thread which sleeps forever (unless it *)
(*       is resumed by one of the functions [wakeup], [wakeup_exn] below) *)
(*       and the corresponding wakener.  This thread does not block the *)
(*       execution of the remainder of the program (except of course, if *)
(*       another thread tries to wait for its termination). *\) *)

(* val wakeup : 'a u -> 'a -> unit *)
(*   (\** [wakeup t e] makes the sleeping thread [t] terminate and return *)
(*       the value of the expression [e]. *\) *)

(* val wakeup_exn : 'a u -> exn -> unit *)
(*   (\** [wakeup_exn t e] makes the sleeping thread [t] fail with the *)
(*       exception [e]. *\) *)

(* val wakeup_later : 'a u -> 'a -> unit *)
(*   (\** Same as {!wakeup} but it is not guaranteed that the thread will *)
(*       be woken up immediately. *\) *)

(* val wakeup_later_exn : 'a u -> exn -> unit *)
(*   (\** Same as {!wakeup_exn} but it is not guaranteed that the thread *)
(*       will be woken up immediately. *\) *)

(* val waiter_of_wakener : 'a u -> 'a t *)
(*   (\** Returns the thread associated to a wakener. *\) *)

(* type +'a result *)
(*   (\** Either a value of type ['a], either an exception. *\) *)

(* val make_value : 'a -> 'a result *)
(*   (\** [value x] creates a result containing the value [x]. *\) *)

(* val make_error : exn -> 'a result *)
(*   (\** [error e] creates a result containing the exception [e]. *\) *)

(* val of_result : 'a result -> 'a t *)
(*   (\** Returns a thread from a result. *\) *)

(* val wakeup_result : 'a u -> 'a result -> unit *)
(*   (\** [wakeup_result t r] makes the sleeping thread [t] terminate with *)
(*       the result [r]. *\) *)

(* val wakeup_later_result : 'a u -> 'a result -> unit *)
(*   (\** Same as {!wakeup_result} but it is not guaranteed that the *)
(*       thread will be woken up immediately. *\) *)

(* (\** {2 Threads state} *\) *)

(* (\** State of a thread *\) *)
(* type 'a state = *)
(*   | Return of 'a *)
(*       (\** The thread which has successfully terminated *\) *)
(*   | Fail of exn *)
(*       (\** The thread raised an exception *\) *)
(*   | Sleep *)
(*       (\** The thread is sleeping *\) *)

(* val state : 'a t -> 'a state *)
(*   (\** [state t] returns the state of a thread *\) *)

(* val is_sleeping : 'a t -> bool *)
(*   (\** [is_sleeping t] returns [true] iff [t] is sleeping. *\) *)

(* (\** {2 Cancelable threads} *\) *)

(* (\** Cancelable threads are the same as regular threads except that *)
(*     they can be canceled. *\) *)

(* exception Canceled *)
(*   (\** Canceled threads fails with this exception *\) *)

(* val task : unit -> 'a t * 'a u *)
(*   (\** [task ()] is the same as [wait ()] except that threads created *)
(*       with [task] can be canceled. *\) *)

(* val on_cancel : 'a t -> (unit -> unit) -> unit *)
(*   (\** [on_cancel t f] executes [f] when [t] is canceled. [f] will be *)
(*       executed before all other threads waiting on [t]. *)

(*       If [f] raises an exception it is given to *)
(*       {!async_exception_hook}. *\) *)

(* val add_task_r : 'a u Lwt_sequence.t -> 'a t *)
(*   (\** [add_task_r seq] creates a sleeping thread, adds its wakener to *)
(*       the right of [seq] and returns its waiter. When the thread is *)
(*       canceled, it is removed from [seq]. *\) *)

(* val add_task_l : 'a u Lwt_sequence.t -> 'a t *)
(*   (\** [add_task_l seq] creates a sleeping thread, adds its wakener to *)
(*       the left of [seq] and returns its waiter. When the thread is *)
(*       canceled, it is removed from [seq]. *\) *)

(* val cancel : 'a t -> unit *)
(*   (\** [cancel t] cancels the threads [t]. This means that the deepest *)
(*       sleeping thread created with [task] and connected to [t] is *)
(*       woken up with the exception {!Canceled}. *)

(*       For example, in the following code: *)

(*       {[ *)
(*         let waiter, wakener = task () in *)
(*         cancel (waiter >> printl "plop") *)
(*       ]} *)

(*       [waiter] will be woken up with {!Canceled}. *)
(*   *\) *)

(* val pick : 'a t list -> 'a t *)
(*   (\** [pick l] is the same as {!choose}, except that it cancels all *)
(*       sleeping threads when one terminates. *)

(*       Note: {!pick} leaves the local values of the current thread *)
(*       unchanged. *\) *)

(* val npick : 'a t list -> 'a list t *)
(*   (\** [npick l] is the same as {!nchoose}, except that it cancels all *)
(*       sleeping threads when one terminates. *)

(*       Note: {!npick} leaves the local values of the current thread *)
(*       unchanged. *\) *)

(* val protected : 'a t -> 'a t *)
(*   (\** [protected thread] creates a new cancelable thread which behave *)
(*       as [thread] except that cancelling it does not cancel *)
(*       [thread]. *\) *)

(* val no_cancel : 'a t -> 'a t *)
(*   (\** [no_cancel thread] creates a thread which behave as [thread] *)
(*       except that it cannot be canceled. *\) *)

(* (\** {2 Pause} *\) *)

(* val pause : unit -> unit t *)
(*   (\** [pause ()] is a sleeping thread which is wake up on the next *)
(*       call to {!wakeup_paused}. A thread created with [pause] can be *)
(*       canceled. *\) *)

(* val wakeup_paused : unit -> unit *)
(*   (\** [wakeup_paused ()] wakes up all threads which suspended *)
(*       themselves with {!pause}. *)

(*       This function is called by the scheduler, before entering the *)
(*       main loop. You usually do not have to call it directly, except *)
(*       if you are writing a custom scheduler. *)

(*       Note that if a paused thread resumes and pauses again, it will not *)
(*       be woken up at this point. *\) *)

(* val paused_count : unit -> int *)
(*   (\** [paused_count ()] returns the number of currently paused *)
(*       threads. *\) *)

(* val register_pause_notifier : (int -> unit) -> unit *)
(*   (\** [register_pause_notifier f] register a function [f] that will be *)
(*       called each time pause is called. The parameter passed to [f] is *)
(*       the new number of threads paused. It is usefull to be able to *)
(*       call {!wakeup_paused} when there is no scheduler *\) *)

(* (\** {2 Misc} *\) *)

(* val on_success : 'a t -> ('a -> unit) -> unit *)
(*   (\** [on_success t f] executes [f] when [t] terminates without *)
(*       failing. If [f] raises an exception it is given to *)
(*       {!async_exception_hook}. *\) *)

(* val on_failure : 'a t -> (exn -> unit) -> unit *)
(*   (\** [on_failure t f] executes [f] when [t] terminates and fails. If *)
(*       [f] raises an exception it is given to *)
(*       {!async_exception_hook}. *\) *)

(* val on_termination : 'a t -> (unit -> unit) -> unit *)
(*   (\** [on_termination t f] executes [f] when [t] terminates. If [f] *)
(*       raises an exception it is given to {!async_exception_hook}. *\) *)

(* val on_any : 'a t -> ('a -> unit) -> (exn -> unit) -> unit *)
(*   (\** [on_any t f g] executes [f] or [g] when [t] terminates. If [f] *)
(*       or [g] raises an exception it is given to *)
(*       {!async_exception_hook}. *\) *)

(* (\**/**\) *)

(* (\* The functions below are probably not useful for the casual user. *)
(*    They provide the basic primitives on which can be built multi- *)
(*    threaded libraries such as Lwt_unix. *\) *)

(* val poll : 'a t -> 'a option *)
(*       (\* [poll e] returns [Some v] if the thread [e] is terminated and *)
(*          returned the value [v].  If the thread failed with some *)
(*          exception, this exception is raised.  If the thread is still *)
(*          running, [poll e] returns [None] without blocking. *\) *)

(* val apply : ('a -> 'b t) -> 'a -> 'b t *)
(*       (\* [apply f e] apply the function [f] to the expression [e].  If *)
(*          an exception is raised during this application, it is caught *)
(*          and the resulting thread fails with this exception. *\) *)
(* (\* Q: Could be called 'glue' or 'trap' or something? *\) *)

(* val backtrace_bind : (exn -> exn) -> 'a t -> ('a -> 'b t) -> 'b t *)
(* val backtrace_catch : (exn -> exn) -> (unit -> 'a t) -> (exn -> 'a t) -> 'a t *)
(* val backtrace_try_bind : (exn -> exn) -> (unit -> 'a t) -> ('a -> 'b t) -> (exn -> 'b t) -> 'b t *)
(* val backtrace_finalize : (exn -> exn) -> (unit -> 'a t) -> (unit -> unit t) -> 'a t *)
end
module Lwt_list : sig
# 1 "../lib_protocol_environment/sigs/v1/lwt_list.mli"
(* Lightweight thread library for OCaml
 * http://www.ocsigen.org/lwt
 * Interface Lwt_list
 * Copyright (C) 2010 Jérémie Dimino
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, with linking exceptions;
 * either version 2.1 of the License, or (at your option) any later
 * version. See COPYING file for details.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *)

(** List helpers *)

(* TEZOS CHANGES

   * import version 2.4.5
   * Remove iter/iteri
*)

(** Note: this module use the same naming convention as
    {!Lwt_stream}. *)

(** {2 List iterators} *)

val map_s : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val map_p : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val mapi_s : (int -> 'a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val mapi_p : (int -> 'a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val rev_map_s : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val rev_map_p : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t

val fold_left_s : ('a -> 'b -> 'a Lwt.t) -> 'a -> 'b list -> 'a Lwt.t

val fold_right_s : ('a -> 'b -> 'b Lwt.t) -> 'a list -> 'b -> 'b Lwt.t

(** {2 List scanning} *)

val for_all_s : ('a -> bool Lwt.t) -> 'a list -> bool Lwt.t

val for_all_p : ('a -> bool Lwt.t) -> 'a list -> bool Lwt.t

val exists_s : ('a -> bool Lwt.t) -> 'a list -> bool Lwt.t

val exists_p : ('a -> bool Lwt.t) -> 'a list -> bool Lwt.t

(** {2 List searching} *)

val find_s : ('a -> bool Lwt.t) -> 'a list -> 'a Lwt.t

val filter_s : ('a -> bool Lwt.t) -> 'a list -> 'a list Lwt.t

val filter_p : ('a -> bool Lwt.t) -> 'a list -> 'a list Lwt.t

val filter_map_s : ('a -> 'b option Lwt.t) -> 'a list -> 'b list Lwt.t

val filter_map_p : ('a -> 'b option Lwt.t) -> 'a list -> 'b list Lwt.t

val partition_s : ('a -> bool Lwt.t) -> 'a list -> ('a list * 'a list) Lwt.t

val partition_p : ('a -> bool Lwt.t) -> 'a list -> ('a list * 'a list) Lwt.t
end
module Raw_hashes : sig
# 1 "../lib_protocol_environment/sigs/v1/raw_hashes.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

val blake2b : MBytes.t -> MBytes.t

val sha256 : MBytes.t -> MBytes.t

val sha512 : MBytes.t -> MBytes.t
end
module Compare : sig
# 1 "../lib_protocol_environment/sigs/v1/compare.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

module type COMPARABLE = sig
  type t

  val compare : t -> t -> int
end

module type S = sig
  type t

  val ( = ) : t -> t -> bool

  val ( <> ) : t -> t -> bool

  val ( < ) : t -> t -> bool

  val ( <= ) : t -> t -> bool

  val ( >= ) : t -> t -> bool

  val ( > ) : t -> t -> bool

  val compare : t -> t -> int

  val equal : t -> t -> bool

  val max : t -> t -> t

  val min : t -> t -> t
end

module Make (P : COMPARABLE) : S with type t := P.t

module Char : S with type t = char

module Bool : S with type t = bool

module Int : S with type t = int

module Int32 : S with type t = int32

module Uint32 : S with type t = int32

module Int64 : S with type t = int64

module Uint64 : S with type t = int64

module Float : S with type t = float

module String : S with type t = string

module Z : S with type t = Z.t

module List (P : COMPARABLE) : S with type t = P.t list

module Option (P : COMPARABLE) : S with type t = P.t option
end
module Data_encoding : sig
# 1 "../lib_protocol_environment/sigs/v1/data_encoding.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** In memory JSON data *)
type json =
  [ `O of (string * json) list
  | `Bool of bool
  | `Float of float
  | `A of json list
  | `Null
  | `String of string ]

type json_schema

type 'a t

type 'a encoding = 'a t

val classify : 'a encoding -> [`Fixed of int | `Dynamic | `Variable]

val splitted : json:'a encoding -> binary:'a encoding -> 'a encoding

val null : unit encoding

val empty : unit encoding

val unit : unit encoding

val constant : string -> unit encoding

val int8 : int encoding

val uint8 : int encoding

val int16 : int encoding

val uint16 : int encoding

val int31 : int encoding

val int32 : int32 encoding

val int64 : int64 encoding

val n : Z.t encoding

val z : Z.t encoding

val bool : bool encoding

val string : string encoding

val bytes : MBytes.t encoding

val float : float encoding

val option : 'a encoding -> 'a option encoding

val string_enum : (string * 'a) list -> 'a encoding

module Fixed : sig
  val string : int -> string encoding

  val bytes : int -> MBytes.t encoding

  val add_padding : 'a encoding -> int -> 'a encoding
end

module Variable : sig
  val string : string encoding

  val bytes : MBytes.t encoding

  val array : ?max_length:int -> 'a encoding -> 'a array encoding

  val list : ?max_length:int -> 'a encoding -> 'a list encoding
end

module Bounded : sig
  val string : int -> string encoding

  val bytes : int -> MBytes.t encoding
end

val dynamic_size :
  ?kind:[`Uint30 | `Uint16 | `Uint8] -> 'a encoding -> 'a encoding

val json : json encoding

val json_schema : json_schema encoding

type 'a field

val req :
  ?title:string -> ?description:string -> string -> 't encoding -> 't field

val opt :
  ?title:string ->
  ?description:string ->
  string ->
  't encoding ->
  't option field

val varopt :
  ?title:string ->
  ?description:string ->
  string ->
  't encoding ->
  't option field

val dft :
  ?title:string ->
  ?description:string ->
  string ->
  't encoding ->
  't ->
  't field

val obj1 : 'f1 field -> 'f1 encoding

val obj2 : 'f1 field -> 'f2 field -> ('f1 * 'f2) encoding

val obj3 : 'f1 field -> 'f2 field -> 'f3 field -> ('f1 * 'f2 * 'f3) encoding

val obj4 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  ('f1 * 'f2 * 'f3 * 'f4) encoding

val obj5 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5) encoding

val obj6 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  'f6 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6) encoding

val obj7 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  'f6 field ->
  'f7 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7) encoding

val obj8 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  'f6 field ->
  'f7 field ->
  'f8 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8) encoding

val obj9 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  'f6 field ->
  'f7 field ->
  'f8 field ->
  'f9 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8 * 'f9) encoding

val obj10 :
  'f1 field ->
  'f2 field ->
  'f3 field ->
  'f4 field ->
  'f5 field ->
  'f6 field ->
  'f7 field ->
  'f8 field ->
  'f9 field ->
  'f10 field ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8 * 'f9 * 'f10) encoding

val tup1 : 'f1 encoding -> 'f1 encoding

val tup2 : 'f1 encoding -> 'f2 encoding -> ('f1 * 'f2) encoding

val tup3 :
  'f1 encoding -> 'f2 encoding -> 'f3 encoding -> ('f1 * 'f2 * 'f3) encoding

val tup4 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4) encoding

val tup5 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5) encoding

val tup6 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  'f6 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6) encoding

val tup7 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  'f6 encoding ->
  'f7 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7) encoding

val tup8 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  'f6 encoding ->
  'f7 encoding ->
  'f8 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8) encoding

val tup9 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  'f6 encoding ->
  'f7 encoding ->
  'f8 encoding ->
  'f9 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8 * 'f9) encoding

val tup10 :
  'f1 encoding ->
  'f2 encoding ->
  'f3 encoding ->
  'f4 encoding ->
  'f5 encoding ->
  'f6 encoding ->
  'f7 encoding ->
  'f8 encoding ->
  'f9 encoding ->
  'f10 encoding ->
  ('f1 * 'f2 * 'f3 * 'f4 * 'f5 * 'f6 * 'f7 * 'f8 * 'f9 * 'f10) encoding

val merge_objs : 'o1 encoding -> 'o2 encoding -> ('o1 * 'o2) encoding

val merge_tups : 'a1 encoding -> 'a2 encoding -> ('a1 * 'a2) encoding

val array : ?max_length:int -> 'a encoding -> 'a array encoding

val list : ?max_length:int -> 'a encoding -> 'a list encoding

val assoc : 'a encoding -> (string * 'a) list encoding

type case_tag = Tag of int | Json_only

type 't case

val case :
  title:string ->
  ?description:string ->
  case_tag ->
  'a encoding ->
  ('t -> 'a option) ->
  ('a -> 't) ->
  't case

type tag_size = [`Uint8 | `Uint16]

val union : ?tag_size:tag_size -> 't case list -> 't encoding

val def :
  string -> ?title:string -> ?description:string -> 't encoding -> 't encoding

val conv :
  ('a -> 'b) -> ('b -> 'a) -> ?schema:json_schema -> 'b encoding -> 'a encoding

val mu :
  string ->
  ?title:string ->
  ?description:string ->
  ('a encoding -> 'a encoding) ->
  'a encoding

type 'a lazy_t

val lazy_encoding : 'a encoding -> 'a lazy_t encoding

val force_decode : 'a lazy_t -> 'a option

val force_bytes : 'a lazy_t -> MBytes.t

val make_lazy : 'a encoding -> 'a -> 'a lazy_t

val apply_lazy :
  fun_value:('a -> 'b) ->
  fun_bytes:(MBytes.t -> 'b) ->
  fun_combine:('b -> 'b -> 'b) ->
  'a lazy_t ->
  'b

module Json : sig
  val schema : ?definitions_path:string -> 'a encoding -> json_schema

  val construct : 't encoding -> 't -> json

  val destruct : 't encoding -> json -> 't

  (** JSON Error *)

  type path = path_item list

  and path_item =
    [ `Field of string  (** A field in an object. *)
    | `Index of int  (** An index in an array. *)
    | `Star  (** Any / every field or index. *)
    | `Next  (** The next element after an array. *) ]

  (** Exception raised by destructors, with the location in the original
      JSON structure and the specific error. *)
  exception Cannot_destruct of (path * exn)

  (** Unexpected kind of data encountered (w/ the expectation). *)
  exception Unexpected of string * string

  (** Some {!union} couldn't be destructed, w/ the reasons for each {!case}. *)
  exception No_case_matched of exn list

  (** Array of unexpected size encountered  (w/ the expectation). *)
  exception Bad_array_size of int * int

  (** Missing field in an object. *)
  exception Missing_field of string

  (** Supernumerary field in an object. *)
  exception Unexpected_field of string

  val print_error :
    ?print_unknown:(Format.formatter -> exn -> unit) ->
    Format.formatter ->
    exn ->
    unit

  (** Helpers for writing encoders. *)
  val cannot_destruct : ('a, Format.formatter, unit, 'b) format4 -> 'a

  val wrap_error : ('a -> 'b) -> 'a -> 'b

  val pp : Format.formatter -> json -> unit
end

module Binary : sig
  val length : 'a encoding -> 'a -> int

  val fixed_length : 'a encoding -> int option

  val read : 'a encoding -> MBytes.t -> int -> int -> (int * 'a) option

  val write : 'a encoding -> 'a -> MBytes.t -> int -> int -> int option

  val to_bytes : 'a encoding -> 'a -> MBytes.t option

  val to_bytes_exn : 'a encoding -> 'a -> MBytes.t

  val of_bytes : 'a encoding -> MBytes.t -> 'a option

  type write_error

  exception Write_error of write_error
end

(** [check_size size encoding] ensures that the binary encoding
    of a value will not be allowed to exceed [size] bytes. The reader
    and the writer fails otherwise. This function do not modify
    the JSON encoding. *)
val check_size : int -> 'a encoding -> 'a encoding
end
module Error_monad : sig
# 1 "../lib_protocol_environment/sigs/v1/error_monad.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos Protocol Implementation - Error Monad *)

(** {2 Error classification} *)

(** Categories of error *)
type error_category =
  [ `Branch  (** Errors that may not happen in another context *)
  | `Temporary  (** Errors that may not happen in a later context *)
  | `Permanent  (** Errors that will happen no matter the context *) ]

(** Custom error handling for economic protocols. *)

type error = ..

val pp : Format.formatter -> error -> unit

(** A JSON error serializer *)
val error_encoding : error Data_encoding.t

val json_of_error : error -> Data_encoding.json

val error_of_json : Data_encoding.json -> error

(** Error information *)
type error_info = {
  category : error_category;
  id : string;
  title : string;
  description : string;
  schema : Data_encoding.json_schema;
}

val pp_info : Format.formatter -> error_info -> unit

(** Retrieves information of registered errors *)
val get_registered_errors : unit -> error_info list

(** For other modules to register specialized error serializers *)
val register_error_kind :
  error_category ->
  id:string ->
  title:string ->
  description:string ->
  ?pp:(Format.formatter -> 'err -> unit) ->
  'err Data_encoding.t ->
  (error -> 'err option) ->
  ('err -> error) ->
  unit

(** Classify an error using the registered kinds *)
val classify_errors : error list -> error_category

(** {2 Monad definition} *)

(** The error monad wrapper type, the error case holds a stack of
    error, initialized by the first call to {!fail} and completed by
    each call to {!trace} as the stack is rewinded. The most general
    error is thus at the top of the error stack, going down to the
    specific error that actually caused the failure. *)
type 'a tzresult = ('a, error list) result

(** A JSON serializer for result of a given type *)
val result_encoding : 'a Data_encoding.t -> 'a tzresult Data_encoding.encoding

(** Sucessful result *)
val ok : 'a -> 'a tzresult

(** Sucessful return *)
val return : 'a -> 'a tzresult Lwt.t

(** Sucessful return of [()] *)
val return_unit : unit tzresult Lwt.t

(** Sucessful return of [None] *)
val return_none : 'a option tzresult Lwt.t

(** [return_some x] is a sucessful return of [Some x] *)
val return_some : 'a -> 'a option tzresult Lwt.t

(** Sucessful return of [[]] *)
val return_nil : 'a list tzresult Lwt.t

(** Sucessful return of [true] *)
val return_true : bool tzresult Lwt.t

(** Sucessful return of [false] *)
val return_false : bool tzresult Lwt.t

(** Erroneous result *)
val error : error -> 'a tzresult

(** Erroneous return *)
val fail : error -> 'a tzresult Lwt.t

(** Non-Lwt bind operator *)
val ( >>? ) : 'a tzresult -> ('a -> 'b tzresult) -> 'b tzresult

(** Bind operator *)
val ( >>=? ) :
  'a tzresult Lwt.t -> ('a -> 'b tzresult Lwt.t) -> 'b tzresult Lwt.t

(** Lwt's bind reexported *)
val ( >>= ) : 'a Lwt.t -> ('a -> 'b Lwt.t) -> 'b Lwt.t

val ( >|= ) : 'a Lwt.t -> ('a -> 'b) -> 'b Lwt.t

(** To operator *)
val ( >>|? ) : 'a tzresult Lwt.t -> ('a -> 'b) -> 'b tzresult Lwt.t

(** Non-Lwt to operator *)
val ( >|? ) : 'a tzresult -> ('a -> 'b) -> 'b tzresult

(** Enrich an error report (or do nothing on a successful result) manually *)
val record_trace : error -> 'a tzresult -> 'a tzresult

(** Automatically enrich error reporting on stack rewind *)
val trace : error -> 'b tzresult Lwt.t -> 'b tzresult Lwt.t

(** Same as record_trace, for unevaluated error *)
val record_trace_eval : (unit -> error tzresult) -> 'a tzresult -> 'a tzresult

(** Same as trace, for unevaluated Lwt error *)
val trace_eval :
  (unit -> error tzresult Lwt.t) -> 'b tzresult Lwt.t -> 'b tzresult Lwt.t

(** Erroneous return on failed assertion *)
val fail_unless : bool -> error -> unit tzresult Lwt.t

(** Erroneous return on successful assertion *)
val fail_when : bool -> error -> unit tzresult Lwt.t

(** {2 In-monad list iterators} *)

(** A {!List.iter} in the monad *)
val iter_s : ('a -> unit tzresult Lwt.t) -> 'a list -> unit tzresult Lwt.t

val iter_p : ('a -> unit tzresult Lwt.t) -> 'a list -> unit tzresult Lwt.t

(** A {!List.map} in the monad *)
val map_s : ('a -> 'b tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t

val map_p : ('a -> 'b tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t

(** A {!List.map2} in the monad *)
val map2 : ('a -> 'b -> 'c tzresult) -> 'a list -> 'b list -> 'c list tzresult

(** A {!List.map2} in the monad *)
val map2_s :
  ('a -> 'b -> 'c tzresult Lwt.t) ->
  'a list ->
  'b list ->
  'c 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

(** A {!List.fold_right} in the monad *)
val fold_right_s :
  ('a -> 'b -> 'b tzresult Lwt.t) -> 'a list -> 'b -> 'b tzresult Lwt.t

(**/**)

type shell_error

type 'a shell_tzresult = ('a, shell_error list) result
end
open Error_monad
module Logging : sig
# 1 "../lib_protocol_environment/sigs/v1/logging.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

val debug : ('a, Format.formatter, unit, unit) format4 -> 'a

val log_info : ('a, Format.formatter, unit, unit) format4 -> 'a

val log_notice : ('a, Format.formatter, unit, unit) format4 -> 'a

val warn : ('a, Format.formatter, unit, unit) format4 -> 'a

val log_error : ('a, Format.formatter, unit, unit) format4 -> 'a

val fatal_error : ('a, Format.formatter, unit, unit) format4 -> 'a

val lwt_debug : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a

val lwt_log_info : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a

val lwt_log_notice : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a

val lwt_warn : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a

val lwt_log_error : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a
end
module Time : sig
# 1 "../lib_protocol_environment/sigs/v1/time.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type t

include Compare.S with type t := t

val add : t -> int64 -> t

val diff : t -> t -> int64

val of_seconds : int64 -> t

val to_seconds : t -> int64

val of_notation : string -> t option

val of_notation_exn : string -> t

val to_notation : t -> string

val encoding : t Data_encoding.t

val rfc_encoding : t Data_encoding.t

val pp_hum : Format.formatter -> t -> unit
end
module Option : sig
# 1 "../lib_protocol_environment/sigs/v1/option.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

val map : f:('a -> 'b) -> 'a option -> 'b option

val apply : f:('a -> 'b option) -> 'a option -> 'b option

val iter : f:('a -> unit) -> 'a option -> unit

val unopt : default:'a -> 'a option -> 'a

val unopt_map : f:('a -> 'b) -> default:'b -> 'a option -> 'b

val first_some : 'a option -> 'a option -> 'a option

val try_with : (unit -> 'a) -> 'a option

val some : 'a -> 'a option
end
module RPC_arg : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_arg.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type 'a t

type 'a arg = 'a t

val make :
  ?descr:string ->
  name:string ->
  destruct:(string -> ('a, string) result) ->
  construct:('a -> string) ->
  unit ->
  'a arg

type descr = {name : string; descr : string option}

val descr : 'a arg -> descr

val int : int arg

val int32 : int32 arg

val int64 : int64 arg

val float : float arg

val string : string arg

val like : 'a arg -> ?descr:string -> string -> 'a arg

type ('a, 'b) eq = Eq : ('a, 'a) eq

val eq : 'a arg -> 'b arg -> ('a, 'b) eq option
end
module RPC_path : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_path.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type ('prefix, 'params) t

type ('prefix, 'params) path = ('prefix, 'params) t

type 'prefix context = ('prefix, 'prefix) path

val root : unit context

val open_root : 'a context

val add_suffix : ('prefix, 'params) path -> string -> ('prefix, 'params) path

val ( / ) : ('prefix, 'params) path -> string -> ('prefix, 'params) path

val add_arg :
  ('prefix, 'params) path -> 'a RPC_arg.t -> ('prefix, 'params * 'a) path

val ( /: ) :
  ('prefix, 'params) path -> 'a RPC_arg.t -> ('prefix, 'params * 'a) path

val add_final_args :
  ('prefix, 'params) path -> 'a RPC_arg.t -> ('prefix, 'params * 'a list) path

val ( /:* ) :
  ('prefix, 'params) path -> 'a RPC_arg.t -> ('prefix, 'params * 'a list) path
end
module RPC_query : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_query.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type 'a t

type 'a query = 'a t

val empty : unit query

type ('a, 'b) field

val field :
  ?descr:string -> string -> 'a RPC_arg.t -> 'a -> ('b -> 'a) -> ('b, 'a) field

val opt_field :
  ?descr:string ->
  string ->
  'a RPC_arg.t ->
  ('b -> 'a option) ->
  ('b, 'a option) field

val flag : ?descr:string -> string -> ('b -> bool) -> ('b, bool) field

val multi_field :
  ?descr:string ->
  string ->
  'a RPC_arg.t ->
  ('b -> 'a list) ->
  ('b, 'a list) field

type ('a, 'b, 'c) open_query

val query : 'b -> ('a, 'b, 'b) open_query

val ( |+ ) :
  ('a, 'b, 'c -> 'd) open_query -> ('a, 'c) field -> ('a, 'b, 'd) open_query

val seal : ('a, 'b, 'a) open_query -> 'a t

type untyped = (string * string) list

exception Invalid of string

val parse : 'a query -> untyped -> 'a
end
module RPC_service : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_service.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** HTTP methods. *)
type meth = [`GET | `POST | `DELETE | `PUT | `PATCH]

type (+'meth, 'prefix, 'params, 'query, 'input, 'output) t
  constraint 'meth = [< meth]

type (+'meth, 'prefix, 'params, 'query, 'input, 'output) service =
  ('meth, 'prefix, 'params, 'query, 'input, 'output) t

val get_service :
  ?description:string ->
  query:'query RPC_query.t ->
  output:'output Data_encoding.t ->
  ('prefix, 'params) RPC_path.t ->
  ([`GET], 'prefix, 'params, 'query, unit, 'output) service

val post_service :
  ?description:string ->
  query:'query RPC_query.t ->
  input:'input Data_encoding.t ->
  output:'output Data_encoding.t ->
  ('prefix, 'params) RPC_path.t ->
  ([`POST], 'prefix, 'params, 'query, 'input, 'output) service

val delete_service :
  ?description:string ->
  query:'query RPC_query.t ->
  output:'output Data_encoding.t ->
  ('prefix, 'params) RPC_path.t ->
  ([`DELETE], 'prefix, 'params, 'query, unit, 'output) service

val patch_service :
  ?description:string ->
  query:'query RPC_query.t ->
  input:'input Data_encoding.t ->
  output:'output Data_encoding.t ->
  ('prefix, 'params) RPC_path.t ->
  ([`PATCH], 'prefix, 'params, 'query, 'input, 'output) service

val put_service :
  ?description:string ->
  query:'query RPC_query.t ->
  input:'input Data_encoding.t ->
  output:'output Data_encoding.t ->
  ('prefix, 'params) RPC_path.t ->
  ([`PUT], 'prefix, 'params, 'query, 'input, 'output) service
end
module RPC_answer : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_answer.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Return type for service handler *)
type 'o t =
  [ `Ok of 'o (* 200 *)
  | `OkStream of 'o stream (* 200 *)
  | `Created of string option (* 201 *)
  | `No_content (* 204 *)
  | `Unauthorized of error list option (* 401 *)
  | `Forbidden of error list option (* 403 *)
  | `Not_found of error list option (* 404 *)
  | `Conflict of error list option (* 409 *)
  | `Error of error list option (* 500 *) ]

and 'a stream = {next : unit -> 'a option Lwt.t; shutdown : unit -> unit}

val return : 'o -> 'o t Lwt.t

val return_stream : 'o stream -> 'o t Lwt.t

val not_found : 'o t Lwt.t

val fail : error list -> 'a t Lwt.t
end
module RPC_directory : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_directory.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Dispatch tree *)
type 'prefix t

type 'prefix directory = 'prefix t

(** Empty list of dispatch trees *)
val empty : 'prefix directory

val map : ('a -> 'b Lwt.t) -> 'b directory -> 'a directory

val prefix : ('pr, 'p) RPC_path.path -> 'p directory -> 'pr directory

val merge : 'a directory -> 'a directory -> 'a directory

(** Possible error while registring services. *)
type step =
  | Static of string
  | Dynamic of RPC_arg.descr
  | DynamicTail of RPC_arg.descr

type conflict =
  | CService of RPC_service.meth
  | CDir
  | CBuilder
  | CTail
  | CTypes of RPC_arg.descr * RPC_arg.descr
  | CType of RPC_arg.descr * string list

exception Conflict of step list * conflict

(** Registring handler in service tree. *)
val register :
  'prefix directory ->
  ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
  ('params -> 'query -> 'input -> 'output tzresult Lwt.t) ->
  'prefix directory

val opt_register :
  'prefix directory ->
  ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
  ('params -> 'query -> 'input -> 'output option tzresult Lwt.t) ->
  'prefix directory

val gen_register :
  'prefix directory ->
  ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
  ('params -> 'query -> 'input -> [< 'output RPC_answer.t] Lwt.t) ->
  'prefix directory

val lwt_register :
  'prefix directory ->
  ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
  ('params -> 'query -> 'input -> 'output Lwt.t) ->
  'prefix directory

(** Registring handler in service tree. Curryfied variant.  *)

val register0 :
  unit directory ->
  ('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->
  ('q -> 'i -> 'o tzresult Lwt.t) ->
  unit directory

val register1 :
  'prefix directory ->
  ('m, 'prefix, unit * 'a, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'q -> 'i -> 'o tzresult Lwt.t) ->
  'prefix directory

val register2 :
  'prefix directory ->
  ('m, 'prefix, (unit * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'q -> 'i -> 'o tzresult Lwt.t) ->
  'prefix directory

val register3 :
  'prefix directory ->
  ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'q -> 'i -> 'o tzresult Lwt.t) ->
  'prefix directory

val register4 :
  'prefix directory ->
  ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> 'o tzresult Lwt.t) ->
  'prefix directory

val register5 :
  'prefix directory ->
  ( 'm,
    'prefix,
    ((((unit * 'a) * 'b) * 'c) * 'd) * 'e,
    'q,
    'i,
    'o )
  RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> 'o tzresult Lwt.t) ->
  'prefix directory

val opt_register0 :
  unit directory ->
  ('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->
  ('q -> 'i -> 'o option tzresult Lwt.t) ->
  unit directory

val opt_register1 :
  'prefix directory ->
  ('m, 'prefix, unit * 'a, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
  'prefix directory

val opt_register2 :
  'prefix directory ->
  ('m, 'prefix, (unit * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
  'prefix directory

val opt_register3 :
  'prefix directory ->
  ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
  'prefix directory

val opt_register4 :
  'prefix directory ->
  ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
  'prefix directory

val opt_register5 :
  'prefix directory ->
  ( 'm,
    'prefix,
    ((((unit * 'a) * 'b) * 'c) * 'd) * 'e,
    'q,
    'i,
    'o )
  RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
  'prefix directory

val gen_register0 :
  unit directory ->
  ('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->
  ('q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  unit directory

val gen_register1 :
  'prefix directory ->
  ('m, 'prefix, unit * 'a, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  'prefix directory

val gen_register2 :
  'prefix directory ->
  ('m, 'prefix, (unit * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  'prefix directory

val gen_register3 :
  'prefix directory ->
  ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  'prefix directory

val gen_register4 :
  'prefix directory ->
  ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  'prefix directory

val gen_register5 :
  'prefix directory ->
  ( 'm,
    'prefix,
    ((((unit * 'a) * 'b) * 'c) * 'd) * 'e,
    'q,
    'i,
    'o )
  RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> [< 'o RPC_answer.t] Lwt.t) ->
  'prefix directory

val lwt_register0 :
  unit directory ->
  ('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->
  ('q -> 'i -> 'o Lwt.t) ->
  unit directory

val lwt_register1 :
  'prefix directory ->
  ('m, 'prefix, unit * 'a, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'q -> 'i -> 'o Lwt.t) ->
  'prefix directory

val lwt_register2 :
  'prefix directory ->
  ('m, 'prefix, (unit * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'q -> 'i -> 'o Lwt.t) ->
  'prefix directory

val lwt_register3 :
  'prefix directory ->
  ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'q -> 'i -> 'o Lwt.t) ->
  'prefix directory

val lwt_register4 :
  'prefix directory ->
  ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q, 'i, 'o) RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> 'o Lwt.t) ->
  'prefix directory

val lwt_register5 :
  'prefix directory ->
  ( 'm,
    'prefix,
    ((((unit * 'a) * 'b) * 'c) * 'd) * 'e,
    'q,
    'i,
    'o )
  RPC_service.t ->
  ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> 'o Lwt.t) ->
  'prefix directory

(** Registring dynamic subtree. *)
val register_dynamic_directory :
  ?descr:string ->
  'prefix directory ->
  ('prefix, 'a) RPC_path.t ->
  ('a -> 'a directory Lwt.t) ->
  'prefix directory
end
module Base58 : sig
# 1 "../lib_protocol_environment/sigs/v1/base58.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type 'a encoding

val simple_decode : 'a encoding -> string -> 'a option

val simple_encode : 'a encoding -> 'a -> string

type data = ..

val register_encoding :
  prefix:string ->
  length:int ->
  to_raw:('a -> string) ->
  of_raw:(string -> 'a option) ->
  wrap:('a -> data) ->
  'a encoding

val check_encoded_prefix : 'a encoding -> string -> int -> unit

val decode : string -> data option
end
module S : sig
# 1 "../lib_protocol_environment/sigs/v1/s.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Generic interface for a datatype with comparison, pretty-printer
    and serialization functions. *)
module type T = sig
  type t

  include Compare.S with type t := t

  val pp : Format.formatter -> t -> unit

  val encoding : t Data_encoding.t

  val to_bytes : t -> MBytes.t

  val of_bytes : MBytes.t -> t option
end

(** Generic interface for a datatype with comparison, pretty-printer,
    serialization functions and a hashing function. *)
module type HASHABLE = sig
  include T

  type hash

  val hash : t -> hash

  val hash_raw : MBytes.t -> hash
end

(** {2 Hash Types} *)

(** The signature of an abstract hash type, as produced by functor
    {!Make_SHA256}. The {!t} type is abstracted for separating the
    various kinds of hashes in the system at typing time. Each type is
    equipped with functions to use it as is of as keys in the database
    or in memory sets and maps. *)

module type MINIMAL_HASH = sig
  type t

  val name : string

  val title : string

  val pp : Format.formatter -> t -> unit

  val pp_short : Format.formatter -> t -> unit

  include Compare.S with type t := t

  val hash_bytes : ?key:MBytes.t -> MBytes.t list -> t

  val hash_string : ?key:string -> string list -> t

  val zero : t
end

module type RAW_DATA = sig
  type t

  val size : int (* in bytes *)

  val to_bytes : t -> MBytes.t

  val of_bytes_opt : MBytes.t -> t option

  val of_bytes_exn : MBytes.t -> t
end

module type B58_DATA = sig
  type t

  val to_b58check : t -> string

  val to_short_b58check : t -> string

  val of_b58check_exn : string -> t

  val of_b58check_opt : string -> t option

  type Base58.data += Data of t

  val b58check_encoding : t Base58.encoding
end

module type ENCODER = sig
  type t

  val encoding : t Data_encoding.t

  val rpc_arg : t RPC_arg.t
end

module type SET = sig
  type elt

  type t

  val empty : t

  val is_empty : t -> bool

  val mem : elt -> t -> bool

  val add : elt -> t -> t

  val singleton : elt -> t

  val remove : elt -> t -> t

  val union : t -> t -> t

  val inter : t -> t -> t

  val diff : t -> t -> t

  val compare : t -> t -> int

  val equal : t -> t -> bool

  val subset : t -> t -> bool

  val iter : (elt -> unit) -> t -> unit

  val map : (elt -> elt) -> t -> t

  val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a

  val for_all : (elt -> bool) -> t -> bool

  val exists : (elt -> bool) -> t -> bool

  val filter : (elt -> bool) -> t -> t

  val partition : (elt -> bool) -> t -> t * t

  val cardinal : t -> int

  val elements : t -> elt list

  val min_elt_opt : t -> elt option

  val max_elt_opt : t -> elt option

  val choose_opt : t -> elt option

  val split : elt -> t -> t * bool * t

  val find_opt : elt -> t -> elt option

  val find_first_opt : (elt -> bool) -> t -> elt option

  val find_last_opt : (elt -> bool) -> t -> elt option

  val of_list : elt list -> t
end

module type MAP = sig
  type key

  type +'a t

  val empty : 'a t

  val is_empty : 'a t -> bool

  val mem : key -> 'a t -> bool

  val add : key -> 'a -> 'a t -> 'a t

  val update : key -> ('a option -> 'a option) -> 'a t -> 'a t

  val singleton : key -> 'a -> 'a t

  val remove : key -> 'a t -> 'a t

  val merge :
    (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t

  val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t

  val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

  val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

  val iter : (key -> 'a -> unit) -> 'a t -> unit

  val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b

  val for_all : (key -> 'a -> bool) -> 'a t -> bool

  val exists : (key -> 'a -> bool) -> 'a t -> bool

  val filter : (key -> 'a -> bool) -> 'a t -> 'a t

  val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t

  val cardinal : 'a t -> int

  val bindings : 'a t -> (key * 'a) list

  val min_binding_opt : 'a t -> (key * 'a) option

  val max_binding_opt : 'a t -> (key * 'a) option

  val choose_opt : 'a t -> (key * 'a) option

  val split : key -> 'a t -> 'a t * 'a option * 'a t

  val find_opt : key -> 'a t -> 'a option

  val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option

  val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option

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

  val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
end

module type INDEXES_Set = sig
  include Stdlib.Set.S

  val encoding : t Data_encoding.t
end

module type INDEXES_Map = sig
  include Stdlib.Map.S

  val encoding : 'a Data_encoding.t -> 'a t Data_encoding.t
end

module type INDEXES = sig
  type t

  val to_path : t -> string list -> string list

  val of_path : string list -> t option

  val of_path_exn : string list -> t

  val prefix_path : string -> string list

  val path_length : int

  module Set : INDEXES_Set with type elt = t

  module Map : INDEXES_Map with type key = t
end

module type HASH = sig
  include MINIMAL_HASH

  include RAW_DATA with type t := t

  include B58_DATA with type t := t

  include ENCODER with type t := t

  include INDEXES with type t := t
end

module type MERKLE_TREE = sig
  type elt

  include HASH

  val compute : elt list -> t

  val empty : t

  type path = Left of path * t | Right of t * path | Op

  val compute_path : elt list -> int -> path

  val check_path : path -> elt -> t * int

  val path_encoding : path Data_encoding.t
end

module type SPublic_key_hash = sig
  type t

  val pp : Format.formatter -> t -> unit

  val pp_short : Format.formatter -> t -> unit

  include Compare.S with type t := t

  include RAW_DATA with type t := t

  include B58_DATA with type t := t

  include ENCODER with type t := t

  include INDEXES with type t := t

  val zero : t
end

module type SPublic_key = sig
  type t

  val pp : Format.formatter -> t -> unit

  include Compare.S with type t := t

  include B58_DATA with type t := t

  include ENCODER with type t := t

  type public_key_hash_t

  val hash : t -> public_key_hash_t
end

module type SIGNATURE = sig
  module Public_key_hash : SPublic_key_hash

  module Public_key :
    SPublic_key with type public_key_hash_t := Public_key_hash.t

  type t

  val pp : Format.formatter -> t -> unit

  include RAW_DATA with type t := t

  include Compare.S with type t := t

  include B58_DATA with type t := t

  include ENCODER with type t := t

  val zero : t

  type watermark

  (** Check a signature *)
  val check : ?watermark:watermark -> Public_key.t -> t -> MBytes.t -> bool
end
end
module Set : sig
# 1 "../lib_protocol_environment/sigs/v1/set.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(** Sets over ordered types.

    This module implements the set data structure, given a total ordering
    function over the set elements. All operations over sets
    are purely applicative (no side-effects).
    The implementation uses balanced binary trees, and is therefore
    reasonably efficient: insertion and membership take time
    logarithmic in the size of the set, for instance.

    The {!Make} functor constructs implementations for any type, given a
    [compare] function.
    For instance:
    {[
      module IntPairs =
      struct
        type t = int * int
        let compare (x0,y0) (x1,y1) =
          match Pervasives.compare x0 x1 with
            0 -> Pervasives.compare y0 y1
          | c -> c
      end

      module PairsSet = Set.Make(IntPairs)

      let m = PairsSet.(empty |> add (2,3) |> add (5,7) |> add (11,13))
    ]}

    This creates a new module [PairsSet], with a new type [PairsSet.t]
    of sets of [int * int].
*)

(** Functor building an implementation of the set structure
    given a totally ordered type. *)
module Make (Ord : Compare.COMPARABLE) : S.SET with type elt = Ord.t
end
module Map : sig
# 1 "../lib_protocol_environment/sigs/v1/map.mli"
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(** Association tables over ordered types.

    This module implements applicative association tables, also known as
    finite maps or dictionaries, given a total ordering function
    over the keys.
    All operations over maps are purely applicative (no side-effects).
    The implementation uses balanced binary trees, and therefore searching
    and insertion take time logarithmic in the size of the map.

    For instance:
    {[
      module IntPairs =
      struct
        type t = int * int
        let compare (x0,y0) (x1,y1) =
          match Pervasives.compare x0 x1 with
            0 -> Pervasives.compare y0 y1
          | c -> c
      end

      module PairsMap = Map.Make(IntPairs)

      let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world")
    ]}

    This creates a new module [PairsMap], with a new type ['a PairsMap.t]
    of maps from [int * int] to ['a]. In this example, [m] contains [string]
    values so its type is [string PairsMap.t].
*)

(** Functor building an implementation of the map structure
    given a totally ordered type. *)
module Make (Ord : Compare.COMPARABLE) : S.MAP with type key = Ord.t
end
module Blake2B : sig
# 1 "../lib_protocol_environment/sigs/v1/blake2B.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Builds a new Hash type using Blake2B. *)

(** The parameters for creating a new Hash type using
    {!Make_Blake2B}. Both {!name} and {!title} are only informative,
    used in error messages and serializers. *)

module type Name = sig
  val name : string

  val title : string

  val size : int option
end

module type PrefixedName = sig
  include Name

  val b58check_prefix : string
end

module Make_minimal (Name : Name) : S.MINIMAL_HASH

module type SRegister = sig
  val register_encoding :
    prefix:string ->
    length:int ->
    to_raw:('a -> string) ->
    of_raw:(string -> 'a option) ->
    wrap:('a -> Base58.data) ->
    'a Base58.encoding
end

module Make (Register : SRegister) (Name : PrefixedName) : S.HASH
end
module Ed25519 : sig
# 1 "../lib_protocol_environment/sigs/v1/ed25519.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos - Ed25519 cryptography *)

include S.SIGNATURE with type watermark := MBytes.t
end
module Secp256k1 : sig
# 1 "../lib_protocol_environment/sigs/v1/secp256k1.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos - Secp256k1 cryptography *)

include S.SIGNATURE with type watermark := MBytes.t
end
module P256 : sig
# 1 "../lib_protocol_environment/sigs/v1/p256.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos - P256 cryptography *)

include S.SIGNATURE with type watermark := MBytes.t
end
module Chain_id : sig
# 1 "../lib_protocol_environment/sigs/v1/chain_id.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

include S.HASH
end
module Signature : sig
# 1 "../lib_protocol_environment/sigs/v1/signature.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

val signature_module_tag : unit

type public_key_hash =
  | Ed25519Hash of Ed25519.Public_key_hash.t
  | Secp256k1Hash of Secp256k1.Public_key_hash.t
  | P256Hash of P256.Public_key_hash.t

type public_key =
  | Ed25519 of Ed25519.Public_key.t
  | Secp256k1 of Secp256k1.Public_key.t
  | P256 of P256.Public_key.t

type watermark =
  | Block_header of Chain_id.t
  | Endorsement of Chain_id.t
  | Generic_operation
  | Custom of MBytes.t

include
  S.SIGNATURE
    with type Public_key_hash.t = public_key_hash
     and type Public_key.t = public_key
     and type watermark := watermark
end
module Block_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/block_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Blocks hashes / IDs. *)
include S.HASH
end
module Operation_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/operation_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Operations hashes / IDs. *)
include S.HASH
end
module Operation_list_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/operation_list_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Blocks hashes / IDs. *)
include
  S.MERKLE_TREE with type elt = Operation_hash.t
end
module Operation_list_list_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/operation_list_list_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Blocks hashes / IDs. *)
include
  S.MERKLE_TREE with type elt = Operation_list_hash.t
end
module Protocol_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/protocol_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Protocol hashes / IDs. *)
include S.HASH
end
module Context_hash : sig
# 1 "../lib_protocol_environment/sigs/v1/context_hash.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Commited context hashes / IDs. *)
include S.HASH
end
module Micheline : sig
# 1 "../lib_protocol_environment/sigs/v1/micheline.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type annot = string list

type ('l, 'p) node =
  | Int of 'l * Z.t
  | String of 'l * string
  | Bytes of 'l * MBytes.t
  | Prim of 'l * 'p * ('l, 'p) node list * annot
  | Seq of 'l * ('l, 'p) node list

type 'p canonical

type canonical_location = int

val root : 'p canonical -> (canonical_location, 'p) node

val canonical_location_encoding : canonical_location Data_encoding.encoding

val canonical_encoding :
  variant:string ->
  'l Data_encoding.encoding ->
  'l canonical Data_encoding.encoding

val canonical_encoding_v1 :
  variant:string ->
  'l Data_encoding.encoding ->
  'l canonical Data_encoding.encoding

(*
val erased_encoding : variant:string -> 'l -> 'p Data_encoding.encoding -> ('l, 'p) node Data_encoding.encoding
val table_encoding : variant:string -> 'l Data_encoding.encoding -> 'p Data_encoding.encoding -> ('l, 'p) node Data_encoding.encoding
*)
val location : ('l, 'p) node -> 'l

val annotations : ('l, 'p) node -> string list

val strip_locations : (_, 'p) node -> 'p canonical

val extract_locations :
  ('l, 'p) node -> 'p canonical * (canonical_location * 'l) list

val inject_locations :
  (canonical_location -> 'l) -> 'p canonical -> ('l, 'p) node
end
module Block_header : sig
# 1 "../lib_protocol_environment/sigs/v1/block_header.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type shell_header = {
  level : Int32.t;
      (** The number of preceding block in this chain, i.e. the genesis
      has level 0. *)
  proto_level : int;
      (** The number of preceding protocol change in the chain (modulo 256),
      i.e. the genesis has proto_level 0. *)
  predecessor : Block_hash.t;
  timestamp : Time.t;
  validation_passes : int;
  operations_hash : Operation_list_list_hash.t;
  fitness : MBytes.t list;
  context : Context_hash.t;
}

val shell_header_encoding : shell_header Data_encoding.t

type t = {shell : shell_header; protocol_data : MBytes.t}

include S.HASHABLE with type t := t and type hash := Block_hash.t
end
module Fitness : sig
# 1 "../lib_protocol_environment/sigs/v1/fitness.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** The fitness of a block is defined as a list of bytes,
    compared in a lexicographical order (longer list are greater). *)
include
  S.T with type t = MBytes.t list
end
module Operation : sig
# 1 "../lib_protocol_environment/sigs/v1/operation.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos operations. *)

type shell_header = {
  branch : Block_hash.t;
      (** The operation is only valid in a branch containing the
      block [branch]. *)
}

val shell_header_encoding : shell_header Data_encoding.t

type t = {shell : shell_header; proto : MBytes.t}

include S.HASHABLE with type t := t and type hash := Operation_hash.t
end
module Protocol : sig
# 1 "../lib_protocol_environment/sigs/v1/protocol.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** An OCaml source component of a protocol implementation. *)
type component = {
  (* The OCaml module name. *)
  name : string;
  (* The OCaml interface source code *)
  interface : string option;
  (* The OCaml source code *)
  implementation : string;
}

and t = {expected_env : env_version; components : component list}

and env_version = V1

val component_encoding : component Data_encoding.t

val env_version_encoding : env_version Data_encoding.t

include S.HASHABLE with type t := t and type hash := Protocol_hash.t
end
module Context : sig
# 1 "../lib_protocol_environment/sigs/v1/context.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** View over the context store, restricted to types, access and
    functional manipulation of an existing context. *)

type t

(** Keys in (kex x value) database implementations *)
type key = string list

(** Values in (kex x value) database implementations *)
type value = MBytes.t

val mem : t -> key -> bool Lwt.t

val dir_mem : t -> key -> bool Lwt.t

val get : t -> key -> value option Lwt.t

val set : t -> key -> value -> t Lwt.t

(** [copy] returns None if the [from] key is not bound *)
val copy : t -> from:key -> to_:key -> t option Lwt.t

val del : t -> key -> t Lwt.t

val remove_rec : t -> key -> t Lwt.t

type dir_or_key = [`Key of key | `Dir of key]

val fold :
  t ->
  key ->
  init:'a ->
  f:([`Key of key | `Dir of key] -> 'a -> 'a Lwt.t) ->
  'a Lwt.t

val keys : t -> key -> key list Lwt.t

val fold_keys : t -> key -> init:'a -> f:(key -> 'a -> 'a Lwt.t) -> 'a Lwt.t

val register_resolver :
  'a Base58.encoding -> (t -> string -> 'a list Lwt.t) -> unit

val complete : t -> string -> string list Lwt.t
end
module Updater : sig
# 1 "../lib_protocol_environment/sigs/v1/updater.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

(** Tezos Protocol Environment - Protocol updater. *)

(** Validation result: the record returned by the protocol
    on the successfull validation of a block. *)
type validation_result = {
  context : Context.t;
      (** The resulting context, it will be used for the next block. *)
  fitness : Fitness.t;
      (** The effective fitness of the block (to be compared with
      the 'announced' one in the block header. *)
  message : string option;
      (** An optional informative message to be used as in the 'git
      commit' of the block's context. *)
  max_operations_ttl : int;
      (** The "time-to-live" of operation for the next block: any
      operations whose 'branch' is older than 'ttl' blocks in the
      past cannot be included in the next block. *)
  last_allowed_fork_level : Int32.t;
      (** The level of the last block for which the node might consider an
      alternate branch. The shell should consider as invalid any
      branch whose fork point is older than the given level *)
}

type quota = {
  max_size : int;
      (** The maximum size (in bytes) of the serialized list of
      operations. *)
  max_op : int option;
      (** The maximum number of operation.
      [None] means no limit. *)
}

type rpc_context = {
  block_hash : Block_hash.t;
  block_header : Block_header.shell_header;
  context : Context.t;
}

(** This is the signature of a Tezos protocol implementation. It has
    access to the standard library and the Environment module. *)
module type PROTOCOL = sig
  (** The maximum size of a block header in bytes. *)
  val max_block_length : int

  (** The maximum size of an operation in bytes. *)
  val max_operation_data_length : int

  (** The number of validation passes (length of the list) and the
      operation's quota for each pass. *)
  val validation_passes : quota list

  (** The version specific type of blocks. *)
  type block_header_data

  (** Encoding for version specific part of block headers.  *)
  val block_header_data_encoding : block_header_data Data_encoding.t

  (** A fully parsed block header. *)
  type block_header = {
    shell : Block_header.shell_header;
    protocol_data : block_header_data;
  }

  (** Version-specific side information computed by the protocol
      during the validation of a block. Should not include information
      about the evaluation of operations which is handled separately by
      {!operation_metadata}. To be used as an execution trace by tools
      (client, indexer). Not necessary for validation. *)
  type block_header_metadata

  (** Encoding for version-specific block metadata. *)
  val block_header_metadata_encoding : block_header_metadata Data_encoding.t

  (** The version specific type of operations. *)
  type operation_data

  (** Version-specific side information computed by the protocol
      during the validation of each operation, to be used conjointly
      with {!block_header_metadata}. *)
  type operation_receipt

  (** A fully parsed operation. *)
  type operation = {
    shell : Operation.shell_header;
    protocol_data : operation_data;
  }

  (** Encoding for version-specific operation data. *)
  val operation_data_encoding : operation_data Data_encoding.t

  (** Encoding for version-specific operation receipts. *)
  val operation_receipt_encoding : operation_receipt Data_encoding.t

  (** Encoding that mixes an operation data and its receipt. *)
  val operation_data_and_receipt_encoding :
    (operation_data * operation_receipt) Data_encoding.t

  (** The Validation passes in which an operation can appear.
      For instance [[0]] if it only belongs to the first pass.
      An answer of [[]] means that the operation is ill-formed
      and cannot be included at all. *)
  val acceptable_passes : operation -> int list

  (** Basic ordering of operations. [compare_operations op1 op2] means
      that [op1] should appear before [op2] in a block. *)
  val compare_operations : operation -> operation -> int

  (** A functional state that is transmitted through the steps of a
      block validation sequence. It must retain the current state of
      the store (that can be extracted from the outside using
      {!current_context}, and whose final value is produced by
      {!finalize_block}). It can also contain the information that
      must be remembered during the validation, which must be
      immutable (as validator or baker implementations are allowed to
      pause, replay or backtrack during the validation process). *)
  type validation_state

  (** Access the context at a given validation step. *)
  val current_context : validation_state -> Context.t tzresult Lwt.t

  (** Checks that a block is well formed in a given context. This
      function should run quickly, as its main use is to reject bad
      blocks from the chain as early as possible. The input context
      is the one resulting of an ancestor block of same protocol
      version. This ancestor of the current head is guaranteed to be
      more recent than `last_allowed_fork_level`.

      The resulting `validation_state` will be used for multi-pass
      validation. *)
  val begin_partial_application :
    chain_id:Chain_id.t ->
    ancestor_context:Context.t ->
    predecessor_timestamp:Time.t ->
    predecessor_fitness:Fitness.t ->
    block_header ->
    validation_state tzresult Lwt.t

  (** The first step in a block validation sequence. Initializes a
      validation context for validating a block. Takes as argument the
      {!Block_header.t} to initialize the context for this block. The
      function {!precheck_block} may not have been called before
      [begin_application], so all the check performed by the former
      must be repeated in the latter. *)
  val begin_application :
    chain_id:Chain_id.t ->
    predecessor_context:Context.t ->
    predecessor_timestamp:Time.t ->
    predecessor_fitness:Fitness.t ->
    block_header ->
    validation_state tzresult Lwt.t

  (** Initializes a validation context for constructing a new block
      (as opposed to validating an existing block). When the
      [protocol_data] argument is specified, it should contains a
      'prototype' of a the protocol specific part of a block header,
      and the function should produce the exact same effect on the
      context than would produce the validation of a block containing
      an "equivalent" (but complete) header. For instance, if the
      block header usually includes a signature, the header provided
      to {!begin_construction} should includes a faked signature. *)
  val begin_construction :
    chain_id:Chain_id.t ->
    predecessor_context:Context.t ->
    predecessor_timestamp:Time.t ->
    predecessor_level:Int32.t ->
    predecessor_fitness:Fitness.t ->
    predecessor:Block_hash.t ->
    timestamp:Time.t ->
    ?protocol_data:block_header_data ->
    unit ->
    validation_state tzresult Lwt.t

  (** Called after {!begin_application} (or {!begin_construction}) and
      before {!finalize_block}, with each operation in the block. *)
  val apply_operation :
    validation_state ->
    operation ->
    (validation_state * operation_receipt) tzresult Lwt.t

  (** The last step in a block validation sequence. It produces the
      context that will be used as input for the validation of its
      successor block candidates. *)
  val finalize_block :
    validation_state ->
    (validation_result * block_header_metadata) tzresult Lwt.t

  (** The list of remote procedures exported by this implementation *)
  val rpc_services : rpc_context RPC_directory.t

  (** Initialize the context (or upgrade the context after a protocol
      amendment). This function receives the context resulting of the
      application of a block that triggered the amendment. It also
      receives the header of the block that triggered the amendment. *)
  val init :
    Context.t -> Block_header.shell_header -> validation_result tzresult Lwt.t
end

(** Activates a given protocol version from a given context. This
    means that the context used for the next block will use this
    version (this is not an immediate change). The version must have
    been previously compiled successfully. *)
val activate : Context.t -> Protocol_hash.t -> Context.t Lwt.t

(** Fork a test chain. The forkerd chain will use the current block
    as genesis, and [protocol] as economic protocol. The chain will
    be destroyed when a (successor) block will have a timestamp greater
    than [expiration]. The protocol must have been previously compiled
    successfully. *)
val fork_test_chain :
  Context.t -> protocol:Protocol_hash.t -> expiration:Time.t -> Context.t Lwt.t
end
module RPC_context : sig
# 1 "../lib_protocol_environment/sigs/v1/RPC_context.mli"
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

type t = Updater.rpc_context

class type ['pr] simple =
  object
    method call_proto_service0 :
      'm 'q 'i 'o.
      (([< RPC_service.meth] as 'm), t, t, 'q, 'i, 'o) RPC_service.t -> 'pr ->
      'q -> 'i -> 'o Error_monad.shell_tzresult Lwt.t

    method call_proto_service1 :
      'm 'a 'q 'i 'o.
      (([< RPC_service.meth] as 'm), t, t * 'a, 'q, 'i, 'o) RPC_service.t ->
      'pr -> 'a -> 'q -> 'i -> 'o Error_monad.shell_tzresult Lwt.t

    method call_proto_service2 :
      'm 'a 'b 'q 'i 'o.
      ( ([< RPC_service.meth] as 'm),
        t,
        (t * 'a) * 'b,
        'q,
        'i,
        'o )
      RPC_service.t -> 'pr -> 'a -> 'b -> 'q -> 'i ->
      'o Error_monad.shell_tzresult Lwt.t

    method call_proto_service3 :
      'm 'a 'b 'c 'q 'i 'o.
      ( ([< RPC_service.meth] as 'm),
        t,
        ((t * 'a) * 'b) * 'c,
        'q,
        'i,
        'o )
      RPC_service.t -> 'pr -> 'a -> 'b -> 'c -> 'q -> 'i ->
      'o Error_monad.shell_tzresult Lwt.t
  end

val make_call0 :
  ([< RPC_service.meth], t, t, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'q ->
  'i ->
  'o shell_tzresult Lwt.t

val make_call1 :
  ([< RPC_service.meth], t, t * 'a, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'q ->
  'i ->
  'o shell_tzresult Lwt.t

val make_call2 :
  ([< RPC_service.meth], t, (t * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'b ->
  'q ->
  'i ->
  'o shell_tzresult Lwt.t

val make_call3 :
  ([< RPC_service.meth], t, ((t * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'b ->
  'c ->
  'q ->
  'i ->
  'o shell_tzresult Lwt.t

val make_opt_call0 :
  ([< RPC_service.meth], t, t, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'q ->
  'i ->
  'o option shell_tzresult Lwt.t

val make_opt_call1 :
  ([< RPC_service.meth], t, t * 'a, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'q ->
  'i ->
  'o option shell_tzresult Lwt.t

val make_opt_call2 :
  ([< RPC_service.meth], t, (t * 'a) * 'b, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'b ->
  'q ->
  'i ->
  'o option shell_tzresult Lwt.t

val make_opt_call3 :
  ([< RPC_service.meth], t, ((t * 'a) * 'b) * 'c, 'q, 'i, 'o) RPC_service.t ->
  'pr #simple ->
  'pr ->
  'a ->
  'b ->
  'c ->
  'q ->
  'i ->
  'o option shell_tzresult Lwt.t
end
Environment_mli.v
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Set Primitive Projections.
Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.

Module Pervasives.
  Parameter raise : forall {a : Set}, extensible_type -> a.
  
  Parameter raise_notrace : forall {a : Set}, extensible_type -> a.
  
  Parameter invalid_arg : forall {a : Set}, string -> a.
  
  Parameter failwith : forall {a : Set}, string -> a.
  
  (* exception Exit *)
  
  Parameter not : bool -> bool.
  
  Parameter op_andand : bool -> bool -> bool.
  
  Parameter op_pipepipe : bool -> bool -> bool.
  
  Parameter __LOC__ : string.
  
  Parameter __FILE__ : string.
  
  Parameter __LINE__ : int.
  
  Parameter __MODULE__ : string.
  
  Parameter __POS__ : string * int * int * int.
  
  Parameter __LOC_OF__ : forall {a : Set}, a -> string * a.
  
  Parameter __LINE_OF__ : forall {a : Set}, a -> int * a.
  
  Parameter __POS_OF__ : forall {a : Set}, a -> (string * int * int * int) * a.
  
  Parameter op_pipegt : forall {a b : Set}, a -> (a -> b) -> b.
  
  Parameter op_atat : forall {a b : Set}, (a -> b) -> a -> b.
  
  Parameter op_tildeminus : int -> int.
  
  Parameter op_tildeplus : int -> int.
  
  Parameter succ : int -> int.
  
  Parameter pred : int -> int.
  
  Parameter op_plus : int -> int -> int.
  
  Parameter op_minus : int -> int -> int.
  
  Parameter op_star : int -> int -> int.
  
  Parameter op_div : int -> int -> int.
  
  Parameter __mod : int -> int -> int.
  
  Parameter abs : int -> int.
  
  Parameter max_int : int.
  
  Parameter min_int : int.
  
  Parameter land : int -> int -> int.
  
  Parameter lor : int -> int -> int.
  
  Parameter lxor : int -> int -> int.
  
  Parameter lnot : int -> int.
  
  Parameter lsl : int -> int -> int.
  
  Parameter lsr : int -> int -> int.
  
  Parameter asr : int -> int -> int.
  
  Parameter op_caret : string -> string -> string.
  
  Parameter int_of_char : ascii -> int.
  
  Parameter char_of_int : int -> ascii.
  
  Parameter ignore : forall {a : Set}, a -> unit.
  
  Parameter string_of_bool : bool -> string.
  
  Parameter bool_of_string_opt : string -> option bool.
  
  Parameter string_of_int : int -> string.
  
  Parameter int_of_string_opt : string -> option int.
  
  Parameter fst : forall {a b : Set}, a * b -> a.
  
  Parameter snd : forall {a b : Set}, a * b -> b.
  
  Parameter op_at : forall {a : Set}, list a -> list a -> list a.
  
  Module ref.
    Record record {a : Set} : Set := Build {
      contents : a }.
    Arguments record : clear implicits.
    Definition with_contents {t_a} contents (r : record t_a) :=
      Build t_a contents.
  End ref.
  Definition ref := ref.record.
  
  Parameter __ref_value : forall {a : Set}, a -> ref a.
  
  Parameter op_exclamation : forall {a : Set}, ref a -> a.
  
  Parameter op_coloneq : forall {a : Set}, ref a -> a -> unit.
  
  Parameter incr : ref int -> unit.
  
  Parameter decr : ref int -> unit.
  
  Inductive result (a b : Set) : Set :=
  | Ok : a -> result a b
  | Error : b -> result a b.
  
  Arguments Ok {_ _}.
  Arguments Error {_ _}.
  
  Definition format6 (a b c d e f : Set) : Set :=
    CamlinternalFormatBasics.format6 a b c d e f.
  
  Definition format4 (a b c d : Set) : Set := format6 a b c c c d.
  
  Definition format (a b c : Set) : Set := format4 a b c c.
  
  Parameter string_of_format : forall {a b c d e f : Set},
    format6 a b c d e f -> string.
  
  Parameter format_of_string : forall {a b c d e f : Set},
    format6 a b c d e f -> format6 a b c d e f.
  
  Parameter op_caretcaret : forall {a b c d e f g h : Set},
    format6 a b c d e f -> format6 f b c e g h -> format6 a b c d g h.
End Pervasives.

Import Pervasives.

Module Type List_type.
  Parameter length : forall {a : Set}, list a -> int.
  
  Parameter compare_lengths : forall {a b : Set}, list a -> list b -> int.
  
  Parameter compare_length_with : forall {a : Set}, list a -> int -> int.
  
  Parameter __cons_value : forall {a : Set}, a -> list a -> list a.
  
  Parameter hd : forall {a : Set}, list a -> a.
  
  Parameter tl : forall {a : Set}, list a -> list a.
  
  Parameter nth_opt : forall {a : Set}, list a -> int -> option a.
  
  Parameter rev : forall {a : Set}, list a -> list a.
  
  Parameter init : forall {a : Set}, int -> (int -> a) -> list a.
  
  Parameter append : forall {a : Set}, list a -> list a -> list a.
  
  Parameter rev_append : forall {a : Set}, list a -> list a -> list a.
  
  Parameter concat : forall {a : Set}, list (list a) -> list a.
  
  Parameter flatten : forall {a : Set}, list (list a) -> list a.
  
  Parameter iter : forall {a : Set}, (a -> unit) -> list a -> unit.
  
  Parameter iteri : forall {a : Set}, (int -> a -> unit) -> list a -> unit.
  
  Parameter map : forall {a b : Set}, (a -> b) -> list a -> list b.
  
  Parameter mapi : forall {a b : Set}, (int -> a -> b) -> list a -> list b.
  
  Parameter rev_map : forall {a b : Set}, (a -> b) -> list a -> list b.
  
  Parameter fold_left : forall {a b : Set}, (a -> b -> a) -> a -> list b -> a.
  
  Parameter fold_right : forall {a b : Set}, (a -> b -> b) -> list a -> b -> b.
  
  Parameter iter2 : forall {a b : Set},
    (a -> b -> unit) -> list a -> list b -> unit.
  
  Parameter map2 : forall {a b c : Set},
    (a -> b -> c) -> list a -> list b -> list c.
  
  Parameter rev_map2 : forall {a b c : Set},
    (a -> b -> c) -> list a -> list b -> list c.
  
  Parameter fold_left2 : forall {a b c : Set},
    (a -> b -> c -> a) -> a -> list b -> list c -> a.
  
  Parameter fold_right2 : forall {a b c : Set},
    (a -> b -> c -> c) -> list a -> list b -> c -> c.
  
  Parameter for_all : forall {a : Set}, (a -> bool) -> list a -> bool.
  
  Parameter __exists : forall {a : Set}, (a -> bool) -> list a -> bool.
  
  Parameter for_all2 : forall {a b : Set},
    (a -> b -> bool) -> list a -> list b -> bool.
  
  Parameter __exists2 : forall {a b : Set},
    (a -> b -> bool) -> list a -> list b -> bool.
  
  Parameter mem : forall {a : Set}, a -> list a -> bool.
  
  Parameter memq : forall {a : Set}, a -> list a -> bool.
  
  Parameter find_opt : forall {a : Set}, (a -> bool) -> list a -> option a.
  
  Parameter filter : forall {a : Set}, (a -> bool) -> list a -> list a.
  
  Parameter find_all : forall {a : Set}, (a -> bool) -> list a -> list a.
  
  Parameter partition : forall {a : Set},
    (a -> bool) -> list a -> list a * list a.
  
  Parameter assoc_opt : forall {a b : Set}, a -> list (a * b) -> option b.
  
  Parameter assq_opt : forall {a b : Set}, a -> list (a * b) -> option b.
  
  Parameter mem_assoc : forall {a b : Set}, a -> list (a * b) -> bool.
  
  Parameter mem_assq : forall {a b : Set}, a -> list (a * b) -> bool.
  
  Parameter remove_assoc : forall {a b : Set},
    a -> list (a * b) -> list (a * b).
  
  Parameter remove_assq : forall {a b : Set}, a -> list (a * b) -> list (a * b).
  
  Parameter split : forall {a b : Set}, list (a * b) -> list a * list b.
  
  Parameter combine : forall {a b : Set}, list a -> list b -> list (a * b).
  
  Parameter sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  
  Parameter stable_sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  
  Parameter fast_sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  
  Parameter sort_uniq : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  
  Parameter merge : forall {a : Set},
    (a -> a -> int) -> list a -> list a -> list a.
End List_type.

Module List.
  Parameter length : forall {a : Set}, list a -> int.
  Parameter compare_lengths : forall {a b : Set}, list a -> list b -> int.
  Parameter compare_length_with : forall {a : Set}, list a -> int -> int.
  Parameter __cons_value : forall {a : Set}, a -> list a -> list a.
  Parameter hd : forall {a : Set}, list a -> a.
  Parameter tl : forall {a : Set}, list a -> list a.
  Parameter nth_opt : forall {a : Set}, list a -> int -> option a.
  Definition rev : forall {a : Set}, list a -> list a :=
    fun {_} => List.rev.
  Parameter init : forall {a : Set}, int -> (int -> a) -> list a.
  Parameter append : forall {a : Set}, list a -> list a -> list a.
  Parameter rev_append : forall {a : Set}, list a -> list a -> list a.
  Parameter concat : forall {a : Set}, list (list a) -> list a.
  Parameter flatten : forall {a : Set}, list (list a) -> list a.
  Parameter iter : forall {a : Set}, (a -> unit) -> list a -> unit.
  Parameter iteri : forall {a : Set}, (int -> a -> unit) -> list a -> unit.
  Definition map : forall {a b : Set}, (a -> b) -> list a -> list b :=
    fun {_ _} => List.map.
  Parameter mapi : forall {a b : Set}, (int -> a -> b) -> list a -> list b.
  Parameter rev_map : forall {a b : Set}, (a -> b) -> list a -> list b.
  Parameter fold_left : forall {a b : Set}, (a -> b -> a) -> a -> list b -> a.
  Parameter fold_right : forall {a b : Set}, (a -> b -> b) -> list a -> b -> b.
  Parameter iter2 : forall {a b : Set}, (a -> b -> unit) -> list a -> list b -> unit.
  Parameter map2 : forall {a b c : Set}, (a -> b -> c) -> list a -> list b -> list c.
  Parameter rev_map2 : forall {a b c : Set}, (a -> b -> c) -> list a -> list b -> list c.
  Parameter fold_left2 : forall {a b c : Set}, (a -> b -> c -> a) -> a -> list b -> list c -> a.
  Parameter fold_right2 : forall {a b c : Set}, (a -> b -> c -> c) -> list a -> list b -> c -> c.
  Parameter for_all : forall {a : Set}, (a -> bool) -> list a -> bool.
  Parameter __exists : forall {a : Set}, (a -> bool) -> list a -> bool.
  Parameter for_all2 : forall {a b : Set}, (a -> b -> bool) -> list a -> list b -> bool.
  Parameter __exists2 : forall {a b : Set}, (a -> b -> bool) -> list a -> list b -> bool.
  Parameter mem : forall {a : Set}, a -> list a -> bool.
  Parameter memq : forall {a : Set}, a -> list a -> bool.
  Parameter find_opt : forall {a : Set}, (a -> bool) -> list a -> option a.
  Parameter filter : forall {a : Set}, (a -> bool) -> list a -> list a.
  Parameter find_all : forall {a : Set}, (a -> bool) -> list a -> list a.
  Parameter partition : forall {a : Set}, (a -> bool) -> list a -> list a * list a.
  Parameter assoc_opt : forall {a b : Set}, a -> list (a * b) -> option b.
  Parameter assq_opt : forall {a b : Set}, a -> list (a * b) -> option b.
  Parameter mem_assoc : forall {a b : Set}, a -> list (a * b) -> bool.
  Parameter mem_assq : forall {a b : Set}, a -> list (a * b) -> bool.
  Parameter remove_assoc : forall {a b : Set}, a -> list (a * b) -> list (a * b).
  Parameter remove_assq : forall {a b : Set}, a -> list (a * b) -> list (a * b).
  Parameter split : forall {a b : Set}, list (a * b) -> list a * list b.
  Parameter combine : forall {a b : Set}, list a -> list b -> list (a * b).
  Parameter sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  Parameter stable_sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  Parameter fast_sort : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  Parameter sort_uniq : forall {a : Set}, (a -> a -> int) -> list a -> list a.
  Parameter merge : forall {a : Set}, (a -> a -> int) -> list a -> list a -> list a.
End List.

Module List_check : List_type := List.

Module String.
  Parameter length : string -> int.
  
  Parameter get : string -> int -> ascii.
  
  Parameter make : int -> ascii -> string.
  
  Parameter init : int -> (int -> ascii) -> string.
  
  Parameter sub : string -> int -> int -> string.
  
  Parameter blit : string -> int -> bytes -> int -> int -> unit.
  
  Parameter concat : string -> list string -> string.
  
  Parameter iter : (ascii -> unit) -> string -> unit.
  
  Parameter iteri : (int -> ascii -> unit) -> string -> unit.
  
  Parameter map : (ascii -> ascii) -> string -> string.
  
  Parameter mapi : (int -> ascii -> ascii) -> string -> string.
  
  Parameter trim : string -> string.
  
  Parameter escaped : string -> string.
  
  Parameter index_opt : string -> ascii -> option int.
  
  Parameter rindex_opt : string -> ascii -> option int.
  
  Parameter index_from_opt : string -> int -> ascii -> option int.
  
  Parameter rindex_from_opt : string -> int -> ascii -> option int.
  
  Parameter contains : string -> ascii -> bool.
  
  Parameter contains_from : string -> int -> ascii -> bool.
  
  Parameter rcontains_from : string -> int -> ascii -> bool.
  
  Parameter uppercase_ascii : string -> string.
  
  Parameter lowercase_ascii : string -> string.
  
  Parameter capitalize_ascii : string -> string.
  
  Parameter uncapitalize_ascii : string -> string.
  
  Definition t : Set := string.
  
  Parameter compare : t -> t -> int.
  
  Parameter equal : t -> t -> bool.
  
  Parameter split_on_char : ascii -> string -> list string.
  
  Parameter get_char : t -> int -> ascii.
  
  Parameter get_uint8 : t -> int -> int.
  
  Parameter get_int8 : t -> int -> int.
  
  Parameter get_uint16 : t -> int -> int.
  
  Parameter get_int16 : t -> int -> int.
  
  Parameter get_int32 : t -> int -> int32.
  
  Parameter get_int64 : t -> int -> int64.
  
  Module LE.
    Parameter get_uint16 : t -> int -> int.
    
    Parameter get_int16 : t -> int -> int.
    
    Parameter get_int32 : t -> int -> int32.
    
    Parameter get_int64 : t -> int -> int64.
  End LE.
End String.

Module Int32.
  Parameter zero : int32.
  
  Parameter one : int32.
  
  Parameter minus_one : int32.
  
  Parameter neg : int32 -> int32.
  
  Parameter add : int32 -> int32 -> int32.
  
  Parameter sub : int32 -> int32 -> int32.
  
  Parameter mul : int32 -> int32 -> int32.
  
  Parameter div : int32 -> int32 -> int32.
  
  Parameter rem : int32 -> int32 -> int32.
  
  Parameter succ : int32 -> int32.
  
  Parameter pred : int32 -> int32.
  
  Parameter abs : int32 -> int32.
  
  Parameter max_int : int32.
  
  Parameter min_int : int32.
  
  Parameter logand : int32 -> int32 -> int32.
  
  Parameter logor : int32 -> int32 -> int32.
  
  Parameter logxor : int32 -> int32 -> int32.
  
  Parameter lognot : int32 -> int32.
  
  Parameter shift_left : int32 -> int -> int32.
  
  Parameter shift_right : int32 -> int -> int32.
  
  Parameter shift_right_logical : int32 -> int -> int32.
  
  Parameter of_int : int -> int32.
  
  Parameter to_int : int32 -> int.
  
  Parameter of_float : float -> int32.
  
  Parameter to_float : int32 -> float.
  
  Parameter of_string : string -> int32.
  
  Parameter of_string_opt : string -> option int32.
  
  Parameter to_string : int32 -> string.
  
  Parameter bits_of_float : float -> int32.
  
  Parameter float_of_bits : int32 -> float.
  
  Definition t : Set := int32.
  
  Parameter compare : t -> t -> int.
  
  Parameter equal : t -> t -> bool.
End Int32.

Module Int64.
  Parameter zero : int64.
  
  Parameter one : int64.
  
  Parameter minus_one : int64.
  
  Parameter neg : int64 -> int64.
  
  Parameter add : int64 -> int64 -> int64.
  
  Parameter sub : int64 -> int64 -> int64.
  
  Parameter mul : int64 -> int64 -> int64.
  
  Parameter div : int64 -> int64 -> int64.
  
  Parameter rem : int64 -> int64 -> int64.
  
  Parameter succ : int64 -> int64.
  
  Parameter pred : int64 -> int64.
  
  Parameter abs : int64 -> int64.
  
  Parameter max_int : int64.
  
  Parameter min_int : int64.
  
  Parameter logand : int64 -> int64 -> int64.
  
  Parameter logor : int64 -> int64 -> int64.
  
  Parameter logxor : int64 -> int64 -> int64.
  
  Parameter lognot : int64 -> int64.
  
  Parameter shift_left : int64 -> int -> int64.
  
  Parameter shift_right : int64 -> int -> int64.
  
  Parameter shift_right_logical : int64 -> int -> int64.
  
  Parameter of_int : int -> int64.
  
  Parameter to_int : int64 -> int.
  
  Parameter of_float : float -> int64.
  
  Parameter to_float : int64 -> float.
  
  Parameter of_int32 : int32 -> int64.
  
  Parameter to_int32 : int64 -> int32.
  
  Parameter of_nativeint : nativeint -> int64.
  
  Parameter to_nativeint : int64 -> nativeint.
  
  Parameter of_string : string -> int64.
  
  Parameter of_string_opt : string -> option int64.
  
  Parameter to_string : int64 -> string.
  
  Parameter bits_of_float : float -> int64.
  
  Parameter float_of_bits : int64 -> float.
  
  Definition t : Set := int64.
  
  Parameter compare : t -> t -> int.
  
  Parameter equal : t -> t -> bool.
End Int64.

Module Format.
  Parameter formatter : Set.
  
  Parameter pp_open_box : formatter -> int -> unit.
  
  Parameter pp_close_box : formatter -> unit -> unit.
  
  Parameter pp_open_hbox : formatter -> unit -> unit.
  
  Parameter pp_open_vbox : formatter -> int -> unit.
  
  Parameter pp_open_hvbox : formatter -> int -> unit.
  
  Parameter pp_open_hovbox : formatter -> int -> unit.
  
  Parameter pp_print_string : formatter -> string -> unit.
  
  Parameter pp_print_as : formatter -> int -> string -> unit.
  
  Parameter pp_print_int : formatter -> int -> unit.
  
  Parameter pp_print_float : formatter -> float -> unit.
  
  Parameter pp_print_char : formatter -> ascii -> unit.
  
  Parameter pp_print_bool : formatter -> bool -> unit.
  
  Parameter pp_print_space : formatter -> unit -> unit.
  
  Parameter pp_print_cut : formatter -> unit -> unit.
  
  Parameter pp_print_break : formatter -> int -> int -> unit.
  
  Parameter pp_force_newline : formatter -> unit -> unit.
  
  Parameter pp_print_if_newline : formatter -> unit -> unit.
  
  Parameter pp_print_flush : formatter -> unit -> unit.
  
  Parameter pp_print_newline : formatter -> unit -> unit.
  
  Parameter pp_set_margin : formatter -> int -> unit.
  
  Parameter pp_get_margin : formatter -> unit -> int.
  
  Parameter pp_set_max_indent : formatter -> int -> unit.
  
  Parameter pp_get_max_indent : formatter -> unit -> int.
  
  Parameter pp_set_max_boxes : formatter -> int -> unit.
  
  Parameter pp_get_max_boxes : formatter -> unit -> int.
  
  Parameter pp_over_max_boxes : formatter -> unit -> bool.
  
  Parameter pp_open_tbox : formatter -> unit -> unit.
  
  Parameter pp_close_tbox : formatter -> unit -> unit.
  
  Parameter pp_set_tab : formatter -> unit -> unit.
  
  Parameter pp_print_tab : formatter -> unit -> unit.
  
  Parameter pp_print_tbreak : formatter -> int -> int -> unit.
  
  Parameter pp_set_ellipsis_text : formatter -> string -> unit.
  
  Parameter pp_get_ellipsis_text : formatter -> unit -> string.
  
  Definition tag : Set := string.
  
  Parameter pp_open_tag : formatter -> string -> unit.
  
  Parameter pp_close_tag : formatter -> unit -> unit.
  
  Parameter pp_set_tags : formatter -> bool -> unit.
  
  Parameter pp_set_print_tags : formatter -> bool -> unit.
  
  Parameter pp_set_mark_tags : formatter -> bool -> unit.
  
  Parameter pp_get_print_tags : formatter -> unit -> bool.
  
  Parameter pp_get_mark_tags : formatter -> unit -> bool.
  
  Parameter pp_print_list : forall {a : Set},
    option (formatter -> unit -> unit) -> (formatter -> a -> unit) ->
    formatter -> list a -> unit.
  
  Parameter pp_print_text : formatter -> string -> unit.
  
  Parameter fprintf : forall {a : Set},
    formatter -> Pervasives.format a formatter unit -> a.
  
  Parameter sprintf : forall {a : Set}, Pervasives.format a unit string -> a.
  
  Parameter asprintf : forall {a : Set},
    Pervasives.format4 a formatter unit string -> a.
  
  Parameter ifprintf : forall {a : Set},
    formatter -> Pervasives.format a formatter unit -> a.
  
  Parameter kfprintf : forall {a b : Set},
    (formatter -> a) -> formatter -> Pervasives.format4 b formatter unit a -> b.
  
  Parameter ikfprintf : forall {a b : Set},
    (formatter -> a) -> formatter -> Pervasives.format4 b formatter unit a -> b.
  
  Parameter ksprintf : forall {a b : Set},
    (string -> a) -> Pervasives.format4 b unit string a -> b.
  
  Parameter kasprintf : forall {a b : Set},
    (string -> a) -> Pervasives.format4 b formatter unit a -> b.
End Format.

Module Type MBytes_type.
  Parameter t : Set.
  
  Parameter create : int -> t.
  
  Parameter length : t -> int.
  
  Parameter copy : t -> t.
  
  Parameter sub : t -> int -> int -> t.
  
  Parameter blit : t -> int -> t -> int -> int -> unit.
  
  Parameter blit_of_string : string -> int -> t -> int -> int -> unit.
  
  Parameter blit_to_bytes : t -> int -> bytes -> int -> int -> unit.
  
  Parameter of_string : string -> t.
  
  Parameter to_string : t -> string.
  
  Parameter sub_string : t -> int -> int -> string.
  
  Parameter get_char : t -> int -> ascii.
  
  Parameter get_uint8 : t -> int -> int.
  
  Parameter get_int8 : t -> int -> int.
  
  Parameter set_char : t -> int -> ascii -> unit.
  
  Parameter set_int8 : t -> int -> int -> unit.
  
  Parameter get_uint16 : t -> int -> int.
  
  Parameter get_int16 : t -> int -> int.
  
  Parameter get_int32 : t -> int -> int32.
  
  Parameter get_int64 : t -> int -> int64.
  
  Parameter set_int16 : t -> int -> int -> unit.
  
  Parameter set_int32 : t -> int -> int32 -> unit.
  
  Parameter set_int64 : t -> int -> int64 -> unit.
  
  Module LE.
    Parameter get_uint16 : t -> int -> int.
    
    Parameter get_int16 : t -> int -> int.
    
    Parameter get_int32 : t -> int -> int32.
    
    Parameter get_int64 : t -> int -> int64.
    
    Parameter set_int16 : t -> int -> int -> unit.
    
    Parameter set_int32 : t -> int -> int32 -> unit.
    
    Parameter set_int64 : t -> int -> int64 -> unit.
  End LE.
  
  Parameter op_eq : t -> t -> bool.
  
  Parameter op_ltgt : t -> t -> bool.
  
  Parameter op_lt : t -> t -> bool.
  
  Parameter op_lteq : t -> t -> bool.
  
  Parameter op_gteq : t -> t -> bool.
  
  Parameter op_gt : t -> t -> bool.
  
  Parameter compare : t -> t -> int.
  
  Parameter concat : string -> list t -> t.
  
  Inductive hex : Set :=
  | Hex : string -> hex.
  
  Parameter to_hex : t -> hex.
  
  Parameter of_hex : hex -> t.
End MBytes_type.

Module MBytes.
  Definition t : Set := string.
  Parameter create : int -> t.
  Parameter length : t -> int.
  Parameter copy : t -> t.
  Parameter sub : t -> int -> int -> t.
  Parameter blit : t -> int -> t -> int -> int -> unit.
  Parameter blit_of_string : string -> int -> t -> int -> int -> unit.
  Parameter blit_to_bytes : t -> int -> bytes -> int -> int -> unit.
  Definition of_string : string -> t := fun s => s.
  Definition to_string : t -> string := fun b => b.
  Parameter sub_string : t -> int -> int -> string.
  Parameter get_char : t -> int -> ascii.
  Parameter get_uint8 : t -> int -> int.
  Parameter get_int8 : t -> int -> int.
  Parameter set_char : t -> int -> ascii -> unit.
  Parameter set_int8 : t -> int -> int -> unit.
  Parameter get_uint16 : t -> int -> int.
  Parameter get_int16 : t -> int -> int.
  Parameter get_int32 : t -> int -> int32.
  Parameter get_int64 : t -> int -> int64.
  Parameter set_int16 : t -> int -> int -> unit.
  Parameter set_int32 : t -> int -> int32 -> unit.
  Parameter set_int64 : t -> int -> int64 -> unit.

  Module LE.
    Parameter get_uint16 : t -> int -> int.
    Parameter get_int16 : t -> int -> int.
    Parameter get_int32 : t -> int -> int32.
    Parameter get_int64 : t -> int -> int64.
    Parameter set_int16 : t -> int -> int -> unit.
    Parameter set_int32 : t -> int -> int32 -> unit.
    Parameter set_int64 : t -> int -> int64 -> unit.
  End LE.

  Parameter op_eq : t -> t -> bool.
  Parameter op_ltgt : t -> t -> bool.
  Parameter op_lt : t -> t -> bool.
  Parameter op_lteq : t -> t -> bool.
  Parameter op_gteq : t -> t -> bool.
  Parameter op_gt : t -> t -> bool.
  Parameter compare : t -> t -> int.
  Parameter concat : string -> list t -> t.
  
  Inductive hex : Set :=
  | Hex : string -> hex.
  
  Parameter to_hex : t -> hex.
  Parameter of_hex : hex -> t.
End MBytes.

Module MBytes_check : MBytes_type := MBytes.

Module Type Z_type.
  Parameter t : Set.
  
  Parameter zero : t.
  
  Parameter one : t.
  
  Parameter succ : t -> t.
  
  Parameter abs : t -> t.
  
  Parameter neg : t -> t.
  
  Parameter add : t -> t -> t.
  
  Parameter sub : t -> t -> t.
  
  Parameter mul : t -> t -> t.
  
  Parameter ediv_rem : t -> t -> t * t.
  
  Parameter logand : t -> t -> t.
  
  Parameter logor : t -> t -> t.
  
  Parameter logxor : t -> t -> t.
  
  Parameter lognot : t -> t.
  
  Parameter shift_left : t -> int -> t.
  
  Parameter shift_right : t -> int -> t.
  
  Parameter to_string : t -> string.
  
  Parameter of_string : string -> t.
  
  Parameter to_int64 : t -> int64.
  
  Parameter of_int64 : int64 -> t.
  
  Parameter to_int : t -> int.
  
  Parameter of_int : int -> t.
  
  Parameter to_bits : option int -> t -> MBytes.t.
  
  Parameter of_bits : MBytes.t -> t.
  
  Parameter equal : t -> t -> bool.
  
  Parameter compare : t -> t -> int.
  
  Parameter numbits : t -> int.
End Z_type.

Module Z.
  Definition t := Z.
  Definition zero := 0.
  Definition one := 1.
  Definition succ z := Z.add z 1.
  Definition abs := Z.abs.
  Definition neg z := -z.
  Definition add := Z.add.
  Definition sub := Z.sub.
  Definition mul := Z.mul.
  Parameter ediv_rem : t -> t -> t * t.
  Parameter logand : t -> t -> t.
  Parameter logor : t -> t -> t.
  Parameter logxor : t -> t -> t.
  Parameter lognot : t -> t.
  Parameter shift_left : t -> int -> t.
  Parameter shift_right : t -> int -> t.
  Parameter to_string : t -> string.
  Parameter of_string : string -> t.
  Parameter to_int64 : t -> int64.
  Parameter of_int64 : int64 -> t.
  Parameter to_int : t -> int.
  Parameter of_int : int -> t.
  Parameter to_bits : option int -> t -> MBytes.t.
  Parameter of_bits : MBytes.t -> t.
  Definition equal := Z.eqb.
  Parameter compare : t -> t -> int.
  Parameter numbits : t -> int.
End Z.

Module Z_check : Z_type := Z.

Module Type Lwt_type.
  Parameter t : forall (a : Set), Set.
  
  Parameter __return : forall {a : Set}, a -> t a.
  
  Parameter bind : forall {a b : Set}, t a -> (a -> t b) -> t b.
  
  Parameter op_gtgteq : forall {a b : Set}, t a -> (a -> t b) -> t b.
  
  Parameter op_eqltlt : forall {a b : Set}, (a -> t b) -> t a -> t b.
  
  Parameter map : forall {a b : Set}, (a -> b) -> t a -> t b.
  
  Parameter op_gtpipeeq : forall {a b : Set}, t a -> (a -> b) -> t b.
  
  Parameter op_eqpipelt : forall {a b : Set}, (a -> b) -> t a -> t b.
  
  Parameter return_unit : t unit.
  
  Parameter return_none : forall {a : Set}, t (option a).
  
  Parameter return_nil : forall {a : Set}, t (list a).
  
  Parameter return_true : t bool.
  
  Parameter return_false : t bool.
  
  Parameter join : list (t unit) -> t unit.
  
  Parameter op_ltandgt : t unit -> t unit -> t unit.
End Lwt_type.

Module Lwt.
  Definition t (a : Set) : Set := a.
  Definition __return {a : Set} (x : a) : t a := x.
  Definition bind {a b : Set} (x : t a) (f : a -> t b) : t b := f x.
  Definition op_gtgteq {a b : Set} : t a -> (a -> t b) -> t b := bind.
  Definition op_eqltlt {a b : Set} (f : a -> t b) (x : t a) : t b := f x.
  Definition map {a b : Set} (f : a -> b) (x : t a) : t b := f x.
  Definition op_gtpipeeq {a b : Set} (x : t a) (f : a -> b) : t b := f x.
  Definition op_eqpipelt {a b : Set} : (a -> b) -> t a -> t b := map.
  Definition return_unit : t unit := tt.
  Definition return_none {a : Set} : t (option a) := None.
  Definition return_nil {a : Set} : t (list a) := [].
  Definition return_true : t bool := true.
  Definition return_false : t bool := false.
  Parameter join : list (t unit) -> t unit.
  Parameter op_ltandgt : t unit -> t unit -> t unit.
End Lwt.

Module Lwt_check : Lwt_type := Lwt.

Module Lwt_list.
  Parameter map_s : forall {a b : Set},
    (a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter map_p : forall {a b : Set},
    (a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter mapi_s : forall {a b : Set},
    (int -> a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter mapi_p : forall {a b : Set},
    (int -> a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter rev_map_s : forall {a b : Set},
    (a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter rev_map_p : forall {a b : Set},
    (a -> Lwt.t b) -> list a -> Lwt.t (list b).
  
  Parameter fold_left_s : forall {a b : Set},
    (a -> b -> Lwt.t a) -> a -> list b -> Lwt.t a.
  
  Parameter fold_right_s : forall {a b : Set},
    (a -> b -> Lwt.t b) -> list a -> b -> Lwt.t b.
  
  Parameter for_all_s : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t bool.
  
  Parameter for_all_p : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t bool.
  
  Parameter exists_s : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t bool.
  
  Parameter exists_p : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t bool.
  
  Parameter find_s : forall {a : Set}, (a -> Lwt.t bool) -> list a -> Lwt.t a.
  
  Parameter filter_s : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t (list a).
  
  Parameter filter_p : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t (list a).
  
  Parameter filter_map_s : forall {a b : Set},
    (a -> Lwt.t (option b)) -> list a -> Lwt.t (list b).
  
  Parameter filter_map_p : forall {a b : Set},
    (a -> Lwt.t (option b)) -> list a -> Lwt.t (list b).
  
  Parameter partition_s : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t (list a * list a).
  
  Parameter partition_p : forall {a : Set},
    (a -> Lwt.t bool) -> list a -> Lwt.t (list a * list a).
End Lwt_list.

Module Raw_hashes.
  Parameter blake2b : MBytes.t -> MBytes.t.
  
  Parameter sha256 : MBytes.t -> MBytes.t.
  
  Parameter sha512 : MBytes.t -> MBytes.t.
End Raw_hashes.

Module Compare.
  Module COMPARABLE.
    Record signature {t : Set} : Set := {
      t := t;
      compare : t -> t -> int;
    }.
  End COMPARABLE.
  
  Module S.
    Record signature {t : Set} : Set := {
      t := t;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
    }.
  End S.
  
  Parameter Make :
    forall (P : {t : Set & COMPARABLE.signature (t := t)}),
      {_ : unit & S.signature (t := (|P|).(COMPARABLE.t))}.
  
  Parameter Char : {_ : unit & S.signature (t := ascii)}.
  
  Parameter Bool : {_ : unit & S.signature (t := bool)}.
  
  Parameter Int : {_ : unit & S.signature (t := int)}.
  
  Parameter Int32 : {_ : unit & S.signature (t := int32)}.
  
  Parameter Uint32 : {_ : unit & S.signature (t := int32)}.
  
  Parameter Int64 : {_ : unit & S.signature (t := int64)}.
  
  Parameter Uint64 : {_ : unit & S.signature (t := int64)}.
  
  Parameter Float : {_ : unit & S.signature (t := float)}.
  
  Parameter String : {_ : unit & S.signature (t := string)}.
  
  Parameter Z : {_ : unit & S.signature (t := Z.t)}.
  
  Parameter List :
    forall (P : {t : Set & COMPARABLE.signature (t := t)}),
      {_ : unit & S.signature (t := (list (|P|).(COMPARABLE.t)))}.
  
  Parameter Option :
    forall (P : {t : Set & COMPARABLE.signature (t := t)}),
      {_ : unit & S.signature (t := (option (|P|).(COMPARABLE.t)))}.
End Compare.

Module Data_encoding.
  Inductive json : Set :=
  | Bool : bool -> json
  | Null : json
  | O : list (string * json) -> json
  | Float : float -> json
  | String : string -> json
  | A : list json -> json.
  
  Parameter json_schema : Set.
  
  Parameter t : forall (a : Set), Set.
  
  Definition encoding (a : Set) : Set := t a.
  
  Parameter classify : forall {a : Set},
    encoding a -> (* `Variable *) unit + (* `Fixed *) int + (* `Dynamic *) unit.
  
  Parameter splitted : forall {a : Set}, encoding a -> encoding a -> encoding a.
  
  Parameter null : encoding unit.
  
  Parameter empty : encoding unit.
  
  Parameter __unit_value : encoding unit.
  
  Parameter constant : string -> encoding unit.
  
  Parameter int8 : encoding int.
  
  Parameter uint8 : encoding int.
  
  Parameter int16 : encoding int.
  
  Parameter uint16 : encoding int.
  
  Parameter int31 : encoding int.
  
  Parameter __int32_value : encoding int32.
  
  Parameter __int64_value : encoding int64.
  
  Parameter n : encoding Z.t.
  
  Parameter z : encoding Z.t.
  
  Parameter __bool_value : encoding bool.
  
  Parameter __string_value : encoding string.
  
  Parameter __bytes_value : encoding MBytes.t.
  
  Parameter __float_value : encoding float.
  
  Parameter __option_value : forall {a : Set},
    encoding a -> encoding (option a).
  
  Parameter string_enum : forall {a : Set}, list (string * a) -> encoding a.
  
  Module Fixed.
    Parameter __string_value : int -> encoding string.
    
    Parameter __bytes_value : int -> encoding MBytes.t.
    
    Parameter add_padding : forall {a : Set}, encoding a -> int -> encoding a.
  End Fixed.
  
  Module __Variable.
    Parameter __string_value : encoding string.
    
    Parameter __bytes_value : encoding MBytes.t.
    
    Parameter array : forall {a : Set},
      option int -> encoding a -> encoding (array a).
    
    Parameter __list_value : forall {a : Set},
      option int -> encoding a -> encoding (list a).
  End __Variable.
  
  Module Bounded.
    Parameter __string_value : int -> encoding string.
    
    Parameter __bytes_value : int -> encoding MBytes.t.
  End Bounded.
  
  Parameter dynamic_size : forall {a : Set},
    option ((* `Uint16 *) unit + (* `Uint8 *) unit + (* `Uint30 *) unit) ->
    encoding a -> encoding a.
  
  Parameter __json_value : encoding json.
  
  Parameter __json_schema_value : encoding json_schema.
  
  Parameter field : forall (a : Set), Set.
  
  Parameter req : forall {t : Set},
    option string -> option string -> string -> encoding t -> field t.
  
  Parameter opt : forall {t : Set},
    option string -> option string -> string -> encoding t -> field (option t).
  
  Parameter varopt : forall {t : Set},
    option string -> option string -> string -> encoding t -> field (option t).
  
  Parameter dft : forall {t : Set},
    option string -> option string -> string -> encoding t -> t -> field t.
  
  Parameter obj1 : forall {f1 : Set}, field f1 -> encoding f1.
  
  Parameter obj2 : forall {f1 f2 : Set},
    field f1 -> field f2 -> encoding (f1 * f2).
  
  Parameter obj3 : forall {f1 f2 f3 : Set},
    field f1 -> field f2 -> field f3 -> encoding (f1 * f2 * f3).
  
  Parameter obj4 : forall {f1 f2 f3 f4 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> encoding (f1 * f2 * f3 * f4).
  
  Parameter obj5 : forall {f1 f2 f3 f4 f5 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 ->
    encoding (f1 * f2 * f3 * f4 * f5).
  
  Parameter obj6 : forall {f1 f2 f3 f4 f5 f6 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 -> field f6 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6).
  
  Parameter obj7 : forall {f1 f2 f3 f4 f5 f6 f7 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 -> field f6 ->
    field f7 -> encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7).
  
  Parameter obj8 : forall {f1 f2 f3 f4 f5 f6 f7 f8 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 -> field f6 ->
    field f7 -> field f8 -> encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8).
  
  Parameter obj9 : forall {f1 f2 f3 f4 f5 f6 f7 f8 f9 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 -> field f6 ->
    field f7 -> field f8 -> field f9 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8 * f9).
  
  Parameter obj10 : forall {f1 f10 f2 f3 f4 f5 f6 f7 f8 f9 : Set},
    field f1 -> field f2 -> field f3 -> field f4 -> field f5 -> field f6 ->
    field f7 -> field f8 -> field f9 -> field f10 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8 * f9 * f10).
  
  Parameter tup1 : forall {f1 : Set}, encoding f1 -> encoding f1.
  
  Parameter tup2 : forall {f1 f2 : Set},
    encoding f1 -> encoding f2 -> encoding (f1 * f2).
  
  Parameter tup3 : forall {f1 f2 f3 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding (f1 * f2 * f3).
  
  Parameter tup4 : forall {f1 f2 f3 f4 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 ->
    encoding (f1 * f2 * f3 * f4).
  
  Parameter tup5 : forall {f1 f2 f3 f4 f5 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding (f1 * f2 * f3 * f4 * f5).
  
  Parameter tup6 : forall {f1 f2 f3 f4 f5 f6 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding f6 -> encoding (f1 * f2 * f3 * f4 * f5 * f6).
  
  Parameter tup7 : forall {f1 f2 f3 f4 f5 f6 f7 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding f6 -> encoding f7 -> encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7).
  
  Parameter tup8 : forall {f1 f2 f3 f4 f5 f6 f7 f8 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding f6 -> encoding f7 -> encoding f8 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8).
  
  Parameter tup9 : forall {f1 f2 f3 f4 f5 f6 f7 f8 f9 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding f6 -> encoding f7 -> encoding f8 -> encoding f9 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8 * f9).
  
  Parameter tup10 : forall {f1 f10 f2 f3 f4 f5 f6 f7 f8 f9 : Set},
    encoding f1 -> encoding f2 -> encoding f3 -> encoding f4 -> encoding f5 ->
    encoding f6 -> encoding f7 -> encoding f8 -> encoding f9 -> encoding f10 ->
    encoding (f1 * f2 * f3 * f4 * f5 * f6 * f7 * f8 * f9 * f10).
  
  Parameter merge_objs : forall {o1 o2 : Set},
    encoding o1 -> encoding o2 -> encoding (o1 * o2).
  
  Parameter merge_tups : forall {a1 a2 : Set},
    encoding a1 -> encoding a2 -> encoding (a1 * a2).
  
  Parameter array : forall {a : Set},
    option int -> encoding a -> encoding (array a).
  
  Parameter __list_value : forall {a : Set},
    option int -> encoding a -> encoding (list a).
  
  Parameter assoc : forall {a : Set},
    encoding a -> encoding (list (string * a)).
  
  Inductive case_tag : Set :=
  | Tag : int -> case_tag
  | Json_only : case_tag.
  
  Parameter case : forall (t : Set), Set.
  
  Parameter __case_value : forall {a t : Set},
    string -> option string -> case_tag -> encoding a -> (t -> option a) ->
    (a -> t) -> case t.
  
  Inductive tag_size : Set :=
  | Uint16 : tag_size
  | Uint8 : tag_size.
  
  Parameter union : forall {t : Set},
    option tag_size -> list (case t) -> encoding t.
  
  Parameter def : forall {t : Set},
    string -> option string -> option string -> encoding t -> encoding t.
  
  Parameter conv : forall {a b : Set},
    (a -> b) -> (b -> a) -> option json_schema -> encoding b -> encoding a.
  
  Parameter mu : forall {a : Set},
    string -> option string -> option string -> (encoding a -> encoding a) ->
    encoding a.
  
  Parameter lazy_t : forall (a : Set), Set.
  
  Parameter lazy_encoding : forall {a : Set}, encoding a -> encoding (lazy_t a).
  
  Parameter force_decode : forall {a : Set}, lazy_t a -> option a.
  
  Parameter force_bytes : forall {a : Set}, lazy_t a -> MBytes.t.
  
  Parameter make_lazy : forall {a : Set}, encoding a -> a -> lazy_t a.
  
  Parameter apply_lazy : forall {a b : Set},
    (a -> b) -> (MBytes.t -> b) -> (b -> b -> b) -> lazy_t a -> b.
  
  Module Json.
    Parameter schema : forall {a : Set},
      option string -> encoding a -> json_schema.
    
    Parameter construct : forall {t : Set}, encoding t -> t -> json.
    
    Parameter destruct : forall {t : Set}, encoding t -> json -> t.
    
    Reserved Notation "'path".
    
    Inductive path_item : Set :=
    | Index : int -> path_item
    | Field : string -> path_item
    | Next : path_item
    | Star : path_item
    
    where "'path" := (list path_item).
    
    Definition path := 'path.
    
    (* exception Cannot_destruct *)
    
    (* exception Unexpected *)
    
    (* exception No_case_matched *)
    
    (* exception Bad_array_size *)
    
    (* exception Missing_field *)
    
    (* exception Unexpected_field *)
    
    Parameter print_error :
      option (Format.formatter -> extensible_type -> unit) ->
      Format.formatter -> extensible_type -> unit.
    
    Parameter cannot_destruct : forall {a b : Set},
      Pervasives.format4 a Format.formatter unit b -> a.
    
    Parameter wrap_error : forall {a b : Set}, (a -> b) -> a -> b.
    
    Parameter pp : Format.formatter -> json -> unit.
  End Json.
  
  Module Binary.
    Parameter length : forall {a : Set}, encoding a -> a -> int.
    
    Parameter fixed_length : forall {a : Set}, encoding a -> option int.
    
    Parameter read : forall {a : Set},
      encoding a -> MBytes.t -> int -> int -> option (int * a).
    
    Parameter write : forall {a : Set},
      encoding a -> a -> MBytes.t -> int -> int -> option int.
    
    Parameter to_bytes : forall {a : Set}, encoding a -> a -> option MBytes.t.
    
    Parameter to_bytes_exn : forall {a : Set}, encoding a -> a -> MBytes.t.
    
    Parameter of_bytes : forall {a : Set}, encoding a -> MBytes.t -> option a.
    
    Parameter write_error : Set.
    
    (* exception Write_error *)
  End Binary.
  
  Parameter check_size : forall {a : Set}, int -> encoding a -> encoding a.
End Data_encoding.

Module Type Error_monad_type.
  Inductive error_category : Set :=
  | Permanent : error_category
  | Temporary : error_category
  | Branch : error_category.
  
  Definition __error : Set := extensible_type.
  
  Parameter pp : Format.formatter -> __error -> unit.
  
  Parameter error_encoding : Data_encoding.t __error.
  
  Parameter json_of_error : __error -> Data_encoding.json.
  
  Parameter error_of_json : Data_encoding.json -> __error.
  
  Module error_info.
    Record record : Set := Build {
      category : error_category;
      id : string;
      title : string;
      description : string;
      schema : Data_encoding.json_schema }.
    Definition with_category category (r : record) :=
      Build category r.(id) r.(title) r.(description) r.(schema).
    Definition with_id id (r : record) :=
      Build r.(category) id r.(title) r.(description) r.(schema).
    Definition with_title title (r : record) :=
      Build r.(category) r.(id) title r.(description) r.(schema).
    Definition with_description description (r : record) :=
      Build r.(category) r.(id) r.(title) description r.(schema).
    Definition with_schema schema (r : record) :=
      Build r.(category) r.(id) r.(title) r.(description) schema.
  End error_info.
  Definition error_info := error_info.record.
  
  Parameter pp_info : Format.formatter -> error_info -> unit.
  
  Parameter get_registered_errors : unit -> list error_info.
  
  Parameter register_error_kind : forall {err : Set},
    error_category -> string -> string -> string ->
    option (Format.formatter -> err -> unit) -> Data_encoding.t err ->
    (__error -> option err) -> (err -> __error) -> unit.
  
  Parameter classify_errors : list __error -> error_category.
  
  Definition tzresult (a : Set) : Set := Pervasives.result a (list __error).
  
  Parameter result_encoding : forall {a : Set},
    Data_encoding.t a -> Data_encoding.encoding (tzresult a).
  
  Parameter ok : forall {a : Set}, a -> tzresult a.
  
  Parameter __return : forall {a : Set}, a -> Lwt.t (tzresult a).
  
  Parameter return_unit : Lwt.t (tzresult unit).
  
  Parameter return_none : forall {a : Set}, Lwt.t (tzresult (option a)).
  
  Parameter return_some : forall {a : Set}, a -> Lwt.t (tzresult (option a)).
  
  Parameter return_nil : forall {a : Set}, Lwt.t (tzresult (list a)).
  
  Parameter return_true : Lwt.t (tzresult bool).
  
  Parameter return_false : Lwt.t (tzresult bool).
  
  Parameter __error_value : forall {a : Set}, __error -> tzresult a.
  
  Parameter fail : forall {a : Set}, __error -> Lwt.t (tzresult a).
  
  Parameter op_gtgtquestion : forall {a b : Set},
    tzresult a -> (a -> tzresult b) -> tzresult b.
  
  Parameter op_gtgteqquestion : forall {a b : Set},
    Lwt.t (tzresult a) -> (a -> Lwt.t (tzresult b)) -> Lwt.t (tzresult b).
  
  Parameter op_gtgteq : forall {a b : Set},
    Lwt.t a -> (a -> Lwt.t b) -> Lwt.t b.
  
  Parameter op_gtpipeeq : forall {a b : Set}, Lwt.t a -> (a -> b) -> Lwt.t b.
  
  Parameter op_gtgtpipequestion : forall {a b : Set},
    Lwt.t (tzresult a) -> (a -> b) -> Lwt.t (tzresult b).
  
  Parameter op_gtpipequestion : forall {a b : Set},
    tzresult a -> (a -> b) -> tzresult b.
  
  Parameter record_trace : forall {a : Set},
    __error -> tzresult a -> tzresult a.
  
  Parameter trace : forall {b : Set},
    __error -> Lwt.t (tzresult b) -> Lwt.t (tzresult b).
  
  Parameter record_trace_eval : forall {a : Set},
    (unit -> tzresult __error) -> tzresult a -> tzresult a.
  
  Parameter trace_eval : forall {b : Set},
    (unit -> Lwt.t (tzresult __error)) -> Lwt.t (tzresult b) ->
    Lwt.t (tzresult b).
  
  Parameter fail_unless : bool -> __error -> Lwt.t (tzresult unit).
  
  Parameter fail_when : bool -> __error -> Lwt.t (tzresult unit).
  
  Parameter iter_s : forall {a : Set},
    (a -> Lwt.t (tzresult unit)) -> list a -> Lwt.t (tzresult unit).
  
  Parameter iter_p : forall {a : Set},
    (a -> Lwt.t (tzresult unit)) -> list a -> Lwt.t (tzresult unit).
  
  Parameter map_s : forall {a b : Set},
    (a -> Lwt.t (tzresult b)) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter map_p : forall {a b : Set},
    (a -> Lwt.t (tzresult b)) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter map2 : forall {a b c : Set},
    (a -> b -> tzresult c) -> list a -> list b -> tzresult (list c).
  
  Parameter map2_s : forall {a b c : Set},
    (a -> b -> Lwt.t (tzresult c)) -> list a -> list b ->
    Lwt.t (tzresult (list c)).
  
  Parameter filter_map_s : forall {a b : Set},
    (a -> Lwt.t (tzresult (option b))) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter fold_left_s : forall {a b : Set},
    (a -> b -> Lwt.t (tzresult a)) -> a -> list b -> Lwt.t (tzresult a).
  
  Parameter fold_right_s : forall {a b : Set},
    (a -> b -> Lwt.t (tzresult b)) -> list a -> b -> Lwt.t (tzresult b).
  
  Parameter shell_error : Set.
  
  Definition shell_tzresult (a : Set) : Set :=
    Pervasives.result a (list shell_error).
End Error_monad_type.

Module Error_monad.
  Inductive error_category : Set :=
  | Permanent : error_category
  | Temporary : error_category
  | Branch : error_category.
  
  Definition __error : Set := extensible_type.
  
  Parameter pp : Format.formatter -> __error -> unit.
  
  Parameter error_encoding : Data_encoding.t __error.
  
  Parameter json_of_error : __error -> Data_encoding.json.
  
  Parameter error_of_json : Data_encoding.json -> __error.
  
  Module error_info.
    Record record : Set := Build {
      category : error_category;
      id : string;
      title : string;
      description : string;
      schema : Data_encoding.json_schema }.
    Definition with_category category (r : record) :=
      Build category r.(id) r.(title) r.(description) r.(schema).
    Definition with_id id (r : record) :=
      Build r.(category) id r.(title) r.(description) r.(schema).
    Definition with_title title (r : record) :=
      Build r.(category) r.(id) title r.(description) r.(schema).
    Definition with_description description (r : record) :=
      Build r.(category) r.(id) r.(title) description r.(schema).
    Definition with_schema schema (r : record) :=
      Build r.(category) r.(id) r.(title) r.(description) schema.
  End error_info.
  Definition error_info := error_info.record.
  
  Parameter pp_info : Format.formatter -> error_info -> unit.
  
  Parameter get_registered_errors : unit -> list error_info.
  
  Parameter register_error_kind : forall {err : Set},
    error_category -> string -> string -> string ->
    option (Format.formatter -> err -> unit) -> Data_encoding.t err ->
    (__error -> option err) -> (err -> __error) -> unit.
  
  Parameter classify_errors : list __error -> error_category.
  
  Definition tzresult (a : Set) : Set := Pervasives.result a (list __error).
  
  Parameter result_encoding : forall {a : Set},
    Data_encoding.t a -> Data_encoding.encoding (tzresult a).
  
  Definition ok {a : Set} (x : a) : tzresult a := Pervasives.Ok x.
  
  Definition __return {a : Set} (x : a) : Lwt.t (tzresult a) :=
    Lwt.__return (ok x).
  
  Parameter return_unit : Lwt.t (tzresult unit).
  
  Parameter return_none : forall {a : Set}, Lwt.t (tzresult (option a)).
  
  Parameter return_some : forall {a : Set}, a -> Lwt.t (tzresult (option a)).
  
  Parameter return_nil : forall {a : Set}, Lwt.t (tzresult (list a)).
  
  Parameter return_true : Lwt.t (tzresult bool).
  
  Parameter return_false : Lwt.t (tzresult bool).
  
  Parameter __error_value : forall {a : Set}, __error -> tzresult a.
  
  Parameter fail : forall {a : Set}, __error -> Lwt.t (tzresult a).
  
  Definition op_gtgtquestion {a b : Set}
    : tzresult a -> (a -> tzresult b) -> tzresult b :=
    fun x f =>
    match x with
    | Pervasives.Ok x => f x
    | Pervasives.Error error => Pervasives.Error error
    end.
  
  Definition op_gtgteqquestion {a b : Set}
    : Lwt.t (tzresult a) -> (a -> Lwt.t (tzresult b)) -> Lwt.t (tzresult b) :=
    fun x f =>
    Lwt.bind x (fun x =>
      match x with
      | Pervasives.Ok x => f x
      | Pervasives.Error error => Lwt.__return (Pervasives.Error error)
      end
    ).
  
  Parameter op_gtgteq : forall {a b : Set},
    Lwt.t a -> (a -> Lwt.t b) -> Lwt.t b.
  
  Parameter op_gtpipeeq : forall {a b : Set}, Lwt.t a -> (a -> b) -> Lwt.t b.
  
  Parameter op_gtgtpipequestion : forall {a b : Set},
    Lwt.t (tzresult a) -> (a -> b) -> Lwt.t (tzresult b).
  
  Parameter op_gtpipequestion : forall {a b : Set},
    tzresult a -> (a -> b) -> tzresult b.
  
  Parameter record_trace : forall {a : Set},
    __error -> tzresult a -> tzresult a.
  
  Parameter trace : forall {b : Set},
    __error -> Lwt.t (tzresult b) -> Lwt.t (tzresult b).
  
  Parameter record_trace_eval : forall {a : Set},
    (unit -> tzresult __error) -> tzresult a -> tzresult a.
  
  Parameter trace_eval : forall {b : Set},
    (unit -> Lwt.t (tzresult __error)) -> Lwt.t (tzresult b) ->
    Lwt.t (tzresult b).
  
  Parameter fail_unless : bool -> __error -> Lwt.t (tzresult unit).
  
  Parameter fail_when : bool -> __error -> Lwt.t (tzresult unit).
  
  Parameter iter_s : forall {a : Set},
    (a -> Lwt.t (tzresult unit)) -> list a -> Lwt.t (tzresult unit).
  
  Parameter iter_p : forall {a : Set},
    (a -> Lwt.t (tzresult unit)) -> list a -> Lwt.t (tzresult unit).
  
  Parameter map_s : forall {a b : Set},
    (a -> Lwt.t (tzresult b)) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter map_p : forall {a b : Set},
    (a -> Lwt.t (tzresult b)) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter map2 : forall {a b c : Set},
    (a -> b -> tzresult c) -> list a -> list b -> tzresult (list c).
  
  Parameter map2_s : forall {a b c : Set},
    (a -> b -> Lwt.t (tzresult c)) -> list a -> list b ->
    Lwt.t (tzresult (list c)).
  
  Parameter filter_map_s : forall {a b : Set},
    (a -> Lwt.t (tzresult (option b))) -> list a -> Lwt.t (tzresult (list b)).
  
  Parameter fold_left_s : forall {a b : Set},
    (a -> b -> Lwt.t (tzresult a)) -> a -> list b -> Lwt.t (tzresult a).
  
  Parameter fold_right_s : forall {a b : Set},
    (a -> b -> Lwt.t (tzresult b)) -> list a -> b -> Lwt.t (tzresult b).
  
  Parameter shell_error : Set.
  
  Definition shell_tzresult (a : Set) : Set :=
    Pervasives.result a (list shell_error).
End Error_monad.

Module Error_monad_check : Error_monad_type := Error_monad.

Import Error_monad.

Module Logging.
  Parameter debug : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter log_info : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter log_notice : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter warn : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter log_error : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter fatal_error : forall {a : Set},
    Pervasives.format4 a Format.formatter unit unit -> a.
  
  Parameter lwt_debug : forall {a : Set},
    Pervasives.format4 a Format.formatter unit (Lwt.t unit) -> a.
  
  Parameter lwt_log_info : forall {a : Set},
    Pervasives.format4 a Format.formatter unit (Lwt.t unit) -> a.
  
  Parameter lwt_log_notice : forall {a : Set},
    Pervasives.format4 a Format.formatter unit (Lwt.t unit) -> a.
  
  Parameter lwt_warn : forall {a : Set},
    Pervasives.format4 a Format.formatter unit (Lwt.t unit) -> a.
  
  Parameter lwt_log_error : forall {a : Set},
    Pervasives.format4 a Format.formatter unit (Lwt.t unit) -> a.
End Logging.

Module Time.
  Parameter t : Set.
  
  Parameter Included_S : {_ : unit & Compare.S.signature (t := t)}.
  
  Definition op_eq : t -> t -> bool := (|Included_S|).(Compare.S.op_eq).
  
  Definition op_ltgt : t -> t -> bool := (|Included_S|).(Compare.S.op_ltgt).
  
  Definition op_lt : t -> t -> bool := (|Included_S|).(Compare.S.op_lt).
  
  Definition op_lteq : t -> t -> bool := (|Included_S|).(Compare.S.op_lteq).
  
  Definition op_gteq : t -> t -> bool := (|Included_S|).(Compare.S.op_gteq).
  
  Definition op_gt : t -> t -> bool := (|Included_S|).(Compare.S.op_gt).
  
  Definition compare : t -> t -> int := (|Included_S|).(Compare.S.compare).
  
  Definition equal : t -> t -> bool := (|Included_S|).(Compare.S.equal).
  
  Definition max : t -> t -> t := (|Included_S|).(Compare.S.max).
  
  Definition min : t -> t -> t := (|Included_S|).(Compare.S.min).
  
  Parameter add : t -> int64 -> t.
  
  Parameter diff : t -> t -> int64.
  
  Parameter of_seconds : int64 -> t.
  
  Parameter to_seconds : t -> int64.
  
  Parameter of_notation : string -> option t.
  
  Parameter of_notation_exn : string -> t.
  
  Parameter to_notation : t -> string.
  
  Parameter encoding : Data_encoding.t t.
  
  Parameter rfc_encoding : Data_encoding.t t.
  
  Parameter pp_hum : Format.formatter -> t -> unit.
End Time.

Module Option.
  Parameter map : forall {a b : Set}, (a -> b) -> option a -> option b.
  
  Parameter apply : forall {a b : Set}, (a -> option b) -> option a -> option b.
  
  Parameter iter : forall {a : Set}, (a -> unit) -> option a -> unit.
  
  Parameter unopt : forall {a : Set}, a -> option a -> a.
  
  Parameter unopt_map : forall {a b : Set}, (a -> b) -> b -> option a -> b.
  
  Parameter first_some : forall {a : Set}, option a -> option a -> option a.
  
  Parameter try_with : forall {a : Set}, (unit -> a) -> option a.
  
  Parameter some : forall {a : Set}, a -> option a.
End Option.

Module RPC_arg.
  Parameter t : forall (a : Set), Set.
  
  Definition arg (a : Set) : Set := t a.
  
  Parameter make : forall {a : Set},
    option string -> string -> (string -> Pervasives.result a string) ->
    (a -> string) -> unit -> arg a.
  
  Module descr.
    Record record : Set := Build {
      name : string;
      descr : option string }.
    Definition with_name name (r : record) :=
      Build name r.(descr).
    Definition with_descr descr (r : record) :=
      Build r.(name) descr.
  End descr.
  Definition descr := descr.record.
  
  Parameter __descr_value : forall {a : Set}, arg a -> descr.
  
  Parameter __int_value : arg int.
  
  Parameter __int32_value : arg int32.
  
  Parameter __int64_value : arg int64.
  
  Parameter __float_value : arg float.
  
  Parameter __string_value : arg string.
  
  Parameter like : forall {a : Set}, arg a -> option string -> string -> arg a.
  
  Inductive eq : Set :=
  | Eq : eq.
  
  Parameter __eq_value : forall {a b : Set}, arg a -> arg b -> option eq.
End RPC_arg.

Module RPC_path.
  Parameter t : forall (prefix params : Set), Set.
  
  Definition path (prefix params : Set) : Set := t prefix params.
  
  Definition context (prefix : Set) : Set := path prefix prefix.
  
  Parameter root : context unit.
  
  Parameter open_root : forall {a : Set}, context a.
  
  Parameter add_suffix : forall {params prefix : Set},
    path prefix params -> string -> path prefix params.
  
  Parameter op_div : forall {params prefix : Set},
    path prefix params -> string -> path prefix params.
  
  Parameter add_arg : forall {a params prefix : Set},
    path prefix params -> RPC_arg.t a -> path prefix (params * a).
  
  Parameter op_divcolon : forall {a params prefix : Set},
    path prefix params -> RPC_arg.t a -> path prefix (params * a).
  
  Parameter add_final_args : forall {a params prefix : Set},
    path prefix params -> RPC_arg.t a -> path prefix (params * list a).
  
  Parameter op_divcolonstar : forall {a params prefix : Set},
    path prefix params -> RPC_arg.t a -> path prefix (params * list a).
End RPC_path.

Module RPC_query.
  Parameter t : forall (a : Set), Set.
  
  Definition query (a : Set) : Set := t a.
  
  Parameter empty : query unit.
  
  Parameter field : forall (a b : Set), Set.
  
  Parameter __field_value : forall {a b : Set},
    option string -> string -> RPC_arg.t a -> a -> (b -> a) -> field b a.
  
  Parameter opt_field : forall {a b : Set},
    option string -> string -> RPC_arg.t a -> (b -> option a) ->
    field b (option a).
  
  Parameter flag : forall {b : Set},
    option string -> string -> (b -> bool) -> field b bool.
  
  Parameter multi_field : forall {a b : Set},
    option string -> string -> RPC_arg.t a -> (b -> list a) -> field b (list a).
  
  Parameter open_query : forall (a b c : Set), Set.
  
  Parameter __query_value : forall {a b : Set}, b -> open_query a b b.
  
  Parameter op_pipeplus : forall {a b c d : Set},
    open_query a b (c -> d) -> field a c -> open_query a b d.
  
  Parameter seal : forall {a b : Set}, open_query a b a -> t a.
  
  Definition untyped : Set := list (string * string).
  
  (* exception Invalid *)
  
  Parameter parse : forall {a : Set}, query a -> untyped -> a.
End RPC_query.

Module RPC_service.
  Inductive meth : Set :=
  | PUT : meth
  | GET : meth
  | DELETE : meth
  | POST : meth
  | PATCH : meth.
  
  Parameter t : forall (prefix params query input output : Set), Set.
  
  Definition service (prefix params query input output : Set) : Set :=
    t prefix params query input output.
  
  Parameter get_service : forall {output params prefix query : Set},
    option string -> RPC_query.t query -> Data_encoding.t output ->
    RPC_path.t prefix params -> service prefix params query unit output.
  
  Parameter post_service : forall {input output params prefix query : Set},
    option string -> RPC_query.t query -> Data_encoding.t input ->
    Data_encoding.t output -> RPC_path.t prefix params ->
    service prefix params query input output.
  
  Parameter delete_service : forall {output params prefix query : Set},
    option string -> RPC_query.t query -> Data_encoding.t output ->
    RPC_path.t prefix params -> service prefix params query unit output.
  
  Parameter patch_service : forall {input output params prefix query : Set},
    option string -> RPC_query.t query -> Data_encoding.t input ->
    Data_encoding.t output -> RPC_path.t prefix params ->
    service prefix params query input output.
  
  Parameter put_service : forall {input output params prefix query : Set},
    option string -> RPC_query.t query -> Data_encoding.t input ->
    Data_encoding.t output -> RPC_path.t prefix params ->
    service prefix params query input output.
End RPC_service.

Module RPC_answer.
  Module stream.
    Record record {next shutdown : Set} : Set := Build {
      next : next;
      shutdown : shutdown }.
    Arguments record : clear implicits.
    Definition with_next {t_next t_shutdown} next
      (r : record t_next t_shutdown) :=
      Build t_next t_shutdown next r.(shutdown).
    Definition with_shutdown {t_next t_shutdown} shutdown
      (r : record t_next t_shutdown) :=
      Build t_next t_shutdown r.(next) shutdown.
  End stream.
  Definition stream_skeleton := stream.record.
  
  Reserved Notation "'stream".
  
  Inductive t (o : Set) : Set :=
  | OkStream : 'stream o -> t o
  | Unauthorized : option (list Error_monad.__error) -> t o
  | Error : option (list Error_monad.__error) -> t o
  | Ok : o -> t o
  | Not_found : option (list Error_monad.__error) -> t o
  | Forbidden : option (list Error_monad.__error) -> t o
  | Created : option string -> t o
  | Conflict : option (list Error_monad.__error) -> t o
  | No_content : t o
  
  where "'stream" := (fun (t_a : Set) =>
    stream_skeleton (unit -> Lwt.t (option t_a)) (unit -> unit)).
  
  Definition stream := 'stream.
  
  Arguments OkStream {_}.
  Arguments Unauthorized {_}.
  Arguments Error {_}.
  Arguments Ok {_}.
  Arguments Not_found {_}.
  Arguments Forbidden {_}.
  Arguments Created {_}.
  Arguments Conflict {_}.
  Arguments No_content {_}.
  
  Parameter __return : forall {o : Set}, o -> Lwt.t (t o).
  
  Parameter return_stream : forall {o : Set}, stream o -> Lwt.t (t o).
  
  Parameter not_found : forall {o : Set}, Lwt.t (t o).
  
  Parameter fail : forall {a : Set}, list Error_monad.__error -> Lwt.t (t a).
End RPC_answer.

Module RPC_directory.
  Parameter t : forall (prefix : Set), Set.
  
  Definition directory (prefix : Set) : Set := t prefix.
  
  Parameter empty : forall {prefix : Set}, directory prefix.
  
  Parameter map : forall {a b : Set},
    (a -> Lwt.t b) -> directory b -> directory a.
  
  Parameter prefix : forall {p pr : Set},
    RPC_path.path pr p -> directory p -> directory pr.
  
  Parameter merge : forall {a : Set}, directory a -> directory a -> directory a.
  
  Inductive step : Set :=
  | Static : string -> step
  | Dynamic : RPC_arg.descr -> step
  | DynamicTail : RPC_arg.descr -> step.
  
  Inductive conflict : Set :=
  | CService : RPC_service.meth -> conflict
  | CDir : conflict
  | CBuilder : conflict
  | CTail : conflict
  | CTypes : RPC_arg.descr -> RPC_arg.descr -> conflict
  | CType : RPC_arg.descr -> list string -> conflict.
  
  (* exception Conflict *)
  
  Parameter register : forall {input output params prefix query : Set},
    directory prefix -> RPC_service.t prefix params query input output ->
    (params -> query -> input -> Lwt.t (Error_monad.tzresult output)) ->
    directory prefix.
  
  Parameter opt_register : forall {input output params prefix query : Set},
    directory prefix -> RPC_service.t prefix params query input output ->
    (params -> query -> input -> Lwt.t (Error_monad.tzresult (option output)))
    -> directory prefix.
  
  Parameter gen_register : forall {input output params prefix query : Set},
    directory prefix -> RPC_service.t prefix params query input output ->
    (params -> query -> input ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream output +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) output +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter lwt_register : forall {input output params prefix query : Set},
    directory prefix -> RPC_service.t prefix params query input output ->
    (params -> query -> input -> Lwt.t output) -> directory prefix.
  
  Parameter register0 : forall {i o q : Set},
    directory unit -> RPC_service.t unit unit q i o ->
    (q -> i -> Lwt.t (Error_monad.tzresult o)) -> directory unit.
  
  Parameter register1 : forall {a i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (unit * a) q i o ->
    (a -> q -> i -> Lwt.t (Error_monad.tzresult o)) -> directory prefix.
  
  Parameter register2 : forall {a b i o prefix q : Set},
    directory prefix -> RPC_service.t prefix ((unit * a) * b) q i o ->
    (a -> b -> q -> i -> Lwt.t (Error_monad.tzresult o)) -> directory prefix.
  
  Parameter register3 : forall {a b c i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (((unit * a) * b) * c) q i o ->
    (a -> b -> c -> q -> i -> Lwt.t (Error_monad.tzresult o)) ->
    directory prefix.
  
  Parameter register4 : forall {a b c d i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix ((((unit * a) * b) * c) * d) q i o ->
    (a -> b -> c -> d -> q -> i -> Lwt.t (Error_monad.tzresult o)) ->
    directory prefix.
  
  Parameter register5 : forall {a b c d e i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix (((((unit * a) * b) * c) * d) * e) q i o ->
    (a -> b -> c -> d -> e -> q -> i -> Lwt.t (Error_monad.tzresult o)) ->
    directory prefix.
  
  Parameter opt_register0 : forall {i o q : Set},
    directory unit -> RPC_service.t unit unit q i o ->
    (q -> i -> Lwt.t (Error_monad.tzresult (option o))) -> directory unit.
  
  Parameter opt_register1 : forall {a i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (unit * a) q i o ->
    (a -> q -> i -> Lwt.t (Error_monad.tzresult (option o))) -> directory prefix.
  
  Parameter opt_register2 : forall {a b i o prefix q : Set},
    directory prefix -> RPC_service.t prefix ((unit * a) * b) q i o ->
    (a -> b -> q -> i -> Lwt.t (Error_monad.tzresult (option o))) ->
    directory prefix.
  
  Parameter opt_register3 : forall {a b c i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (((unit * a) * b) * c) q i o ->
    (a -> b -> c -> q -> i -> Lwt.t (Error_monad.tzresult (option o))) ->
    directory prefix.
  
  Parameter opt_register4 : forall {a b c d i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix ((((unit * a) * b) * c) * d) q i o ->
    (a -> b -> c -> d -> q -> i -> Lwt.t (Error_monad.tzresult (option o))) ->
    directory prefix.
  
  Parameter opt_register5 : forall {a b c d e i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix (((((unit * a) * b) * c) * d) * e) q i o ->
    (a -> b -> c -> d -> e -> q -> i -> Lwt.t (Error_monad.tzresult (option o)))
    -> directory prefix.
  
  Parameter gen_register0 : forall {i o q : Set},
    directory unit -> RPC_service.t unit unit q i o ->
    (q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory unit.
  
  Parameter gen_register1 : forall {a i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (unit * a) q i o ->
    (a -> q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter gen_register2 : forall {a b i o prefix q : Set},
    directory prefix -> RPC_service.t prefix ((unit * a) * b) q i o ->
    (a -> b -> q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter gen_register3 : forall {a b c i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (((unit * a) * b) * c) q i o ->
    (a -> b -> c -> q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter gen_register4 : forall {a b c d i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix ((((unit * a) * b) * c) * d) q i o ->
    (a -> b -> c -> d -> q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter gen_register5 : forall {a b c d e i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix (((((unit * a) * b) * c) * d) * e) q i o ->
    (a -> b -> c -> d -> e -> q -> i ->
    Lwt.t
      ((* `OkStream *) RPC_answer.stream o +
        (* `Unauthorized *) option (list Error_monad.__error) +
        (* `Error *) option (list Error_monad.__error) + (* `Ok *) o +
        (* `Not_found *) option (list Error_monad.__error) +
        (* `Forbidden *) option (list Error_monad.__error) +
        (* `Created *) option string +
        (* `Conflict *) option (list Error_monad.__error) +
        (* `No_content *) unit)) -> directory prefix.
  
  Parameter lwt_register0 : forall {i o q : Set},
    directory unit -> RPC_service.t unit unit q i o -> (q -> i -> Lwt.t o) ->
    directory unit.
  
  Parameter lwt_register1 : forall {a i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (unit * a) q i o ->
    (a -> q -> i -> Lwt.t o) -> directory prefix.
  
  Parameter lwt_register2 : forall {a b i o prefix q : Set},
    directory prefix -> RPC_service.t prefix ((unit * a) * b) q i o ->
    (a -> b -> q -> i -> Lwt.t o) -> directory prefix.
  
  Parameter lwt_register3 : forall {a b c i o prefix q : Set},
    directory prefix -> RPC_service.t prefix (((unit * a) * b) * c) q i o ->
    (a -> b -> c -> q -> i -> Lwt.t o) -> directory prefix.
  
  Parameter lwt_register4 : forall {a b c d i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix ((((unit * a) * b) * c) * d) q i o ->
    (a -> b -> c -> d -> q -> i -> Lwt.t o) -> directory prefix.
  
  Parameter lwt_register5 : forall {a b c d e i o prefix q : Set},
    directory prefix ->
    RPC_service.t prefix (((((unit * a) * b) * c) * d) * e) q i o ->
    (a -> b -> c -> d -> e -> q -> i -> Lwt.t o) -> directory prefix.
  
  Parameter register_dynamic_directory : forall {a prefix : Set},
    option string -> directory prefix -> RPC_path.t prefix a ->
    (a -> Lwt.t (directory a)) -> directory prefix.
End RPC_directory.

Module Base58.
  Parameter encoding : forall (a : Set), Set.
  
  Parameter simple_decode : forall {a : Set}, encoding a -> string -> option a.
  
  Parameter simple_encode : forall {a : Set}, encoding a -> a -> string.
  
  Definition data : Set := extensible_type.
  
  Parameter register_encoding : forall {a : Set},
    string -> int -> (a -> string) -> (string -> option a) -> (a -> data) ->
    encoding a.
  
  Parameter check_encoded_prefix : forall {a : Set},
    encoding a -> string -> int -> unit.
  
  Parameter decode : string -> option data.
End Base58.

Module S.
  Module T.
    Record signature {t : Set} : Set := {
      t := t;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      pp : Format.formatter -> t -> unit;
      encoding : Data_encoding.t t;
      to_bytes : t -> MBytes.t;
      of_bytes : MBytes.t -> option t;
    }.
  End T.
  
  Module HASHABLE.
    Record signature {t hash : Set} : Set := {
      t := t;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      pp : Format.formatter -> t -> unit;
      encoding : Data_encoding.t t;
      to_bytes : t -> MBytes.t;
      of_bytes : MBytes.t -> option t;
      hash := hash;
      __hash_value : t -> hash;
      hash_raw : MBytes.t -> hash;
    }.
  End HASHABLE.
  
  Module MINIMAL_HASH.
    Record signature {t : Set} : Set := {
      t := t;
      name : string;
      title : string;
      pp : Format.formatter -> t -> unit;
      pp_short : Format.formatter -> t -> unit;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      hash_bytes : option MBytes.t -> list MBytes.t -> t;
      hash_string : option string -> list string -> t;
      zero : t;
    }.
  End MINIMAL_HASH.
  
  Module RAW_DATA.
    Record signature {t : Set} : Set := {
      t := t;
      size : int;
      to_bytes : t -> MBytes.t;
      of_bytes_opt : MBytes.t -> option t;
      of_bytes_exn : MBytes.t -> t;
    }.
  End RAW_DATA.
  
  Module B58_DATA.
    Record signature {t : Set} : Set := {
      t := t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type data *)
      b58check_encoding : Base58.encoding t;
    }.
  End B58_DATA.
  
  Module ENCODER.
    Record signature {t : Set} : Set := {
      t := t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
    }.
  End ENCODER.
  
  Module SET.
    Record signature {elt t : Set} : Set := {
      elt := elt;
      t := t;
      empty : t;
      is_empty : t -> bool;
      mem : elt -> t -> bool;
      add : elt -> t -> t;
      singleton : elt -> t;
      remove : elt -> t -> t;
      union : t -> t -> t;
      inter : t -> t -> t;
      diff : t -> t -> t;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      subset : t -> t -> bool;
      iter : (elt -> unit) -> t -> unit;
      map : (elt -> elt) -> t -> t;
      fold : forall {a : Set}, (elt -> a -> a) -> t -> a -> a;
      for_all : (elt -> bool) -> t -> bool;
      __exists : (elt -> bool) -> t -> bool;
      filter : (elt -> bool) -> t -> t;
      partition : (elt -> bool) -> t -> t * t;
      cardinal : t -> int;
      elements : t -> list elt;
      min_elt_opt : t -> option elt;
      max_elt_opt : t -> option elt;
      choose_opt : t -> option elt;
      split : elt -> t -> t * bool * t;
      find_opt : elt -> t -> option elt;
      find_first_opt : (elt -> bool) -> t -> option elt;
      find_last_opt : (elt -> bool) -> t -> option elt;
      of_list : list elt -> t;
    }.
  End SET.
  
  Module MAP.
    Record signature {key : Set} {t : Set -> Set} : Set := {
      key := key;
      t := t;
      empty : forall {a : Set}, t a;
      is_empty : forall {a : Set}, t a -> bool;
      mem : forall {a : Set}, key -> t a -> bool;
      add : forall {a : Set}, key -> a -> t a -> t a;
      update : forall {a : Set}, key -> (option a -> option a) -> t a -> t a;
      singleton : forall {a : Set}, key -> a -> t a;
      remove : forall {a : Set}, key -> t a -> t a;
      merge : forall {a b c : Set},
        (key -> option a -> option b -> option c) -> t a -> t b -> t c;
      union : forall {a : Set},
        (key -> a -> a -> option a) -> t a -> t a -> t a;
      compare : forall {a : Set}, (a -> a -> int) -> t a -> t a -> int;
      equal : forall {a : Set}, (a -> a -> bool) -> t a -> t a -> bool;
      iter : forall {a : Set}, (key -> a -> unit) -> t a -> unit;
      fold : forall {a b : Set}, (key -> a -> b -> b) -> t a -> b -> b;
      for_all : forall {a : Set}, (key -> a -> bool) -> t a -> bool;
      __exists : forall {a : Set}, (key -> a -> bool) -> t a -> bool;
      filter : forall {a : Set}, (key -> a -> bool) -> t a -> t a;
      partition : forall {a : Set}, (key -> a -> bool) -> t a -> t a * t a;
      cardinal : forall {a : Set}, t a -> int;
      bindings : forall {a : Set}, t a -> list (key * a);
      min_binding_opt : forall {a : Set}, t a -> option (key * a);
      max_binding_opt : forall {a : Set}, t a -> option (key * a);
      choose_opt : forall {a : Set}, t a -> option (key * a);
      split : forall {a : Set}, key -> t a -> t a * option a * t a;
      find_opt : forall {a : Set}, key -> t a -> option a;
      find_first_opt : forall {a : Set},
        (key -> bool) -> t a -> option (key * a);
      find_last_opt : forall {a : Set},
        (key -> bool) -> t a -> option (key * a);
      map : forall {a b : Set}, (a -> b) -> t a -> t b;
      mapi : forall {a b : Set}, (key -> a -> b) -> t a -> t b;
    }.
  End MAP.
  
  Module INDEXES_Set.
    Record signature {elt t : Set} : Set := {
      elt := elt;
      t := t;
      empty : t;
      is_empty : t -> bool;
      mem : elt -> t -> bool;
      add : elt -> t -> t;
      singleton : elt -> t;
      remove : elt -> t -> t;
      union : t -> t -> t;
      inter : t -> t -> t;
      diff : t -> t -> t;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      subset : t -> t -> bool;
      iter : (elt -> unit) -> t -> unit;
      map : (elt -> elt) -> t -> t;
      fold : forall {a : Set}, (elt -> a -> a) -> t -> a -> a;
      for_all : (elt -> bool) -> t -> bool;
      __exists : (elt -> bool) -> t -> bool;
      filter : (elt -> bool) -> t -> t;
      partition : (elt -> bool) -> t -> t * t;
      cardinal : t -> int;
      elements : t -> list elt;
      min_elt : t -> elt;
      min_elt_opt : t -> option elt;
      max_elt : t -> elt;
      max_elt_opt : t -> option elt;
      choose : t -> elt;
      choose_opt : t -> option elt;
      split : elt -> t -> t * bool * t;
      find : elt -> t -> elt;
      find_opt : elt -> t -> option elt;
      find_first : (elt -> bool) -> t -> elt;
      find_first_opt : (elt -> bool) -> t -> option elt;
      find_last : (elt -> bool) -> t -> elt;
      find_last_opt : (elt -> bool) -> t -> option elt;
      of_list : list elt -> t;
      to_seq_from : elt -> t -> OCaml.Seq.t elt;
      to_seq : t -> OCaml.Seq.t elt;
      add_seq : OCaml.Seq.t elt -> t -> t;
      of_seq : OCaml.Seq.t elt -> t;
      encoding : Data_encoding.t t;
    }.
  End INDEXES_Set.
  
  Module INDEXES_Map.
    Record signature {key : Set} {t : Set -> Set} : Set := {
      key := key;
      t := t;
      empty : forall {a : Set}, t a;
      is_empty : forall {a : Set}, t a -> bool;
      mem : forall {a : Set}, key -> t a -> bool;
      add : forall {a : Set}, key -> a -> t a -> t a;
      update : forall {a : Set}, key -> (option a -> option a) -> t a -> t a;
      singleton : forall {a : Set}, key -> a -> t a;
      remove : forall {a : Set}, key -> t a -> t a;
      merge : forall {a b c : Set},
        (key -> option a -> option b -> option c) -> t a -> t b -> t c;
      union : forall {a : Set},
        (key -> a -> a -> option a) -> t a -> t a -> t a;
      compare : forall {a : Set}, (a -> a -> int) -> t a -> t a -> int;
      equal : forall {a : Set}, (a -> a -> bool) -> t a -> t a -> bool;
      iter : forall {a : Set}, (key -> a -> unit) -> t a -> unit;
      fold : forall {a b : Set}, (key -> a -> b -> b) -> t a -> b -> b;
      for_all : forall {a : Set}, (key -> a -> bool) -> t a -> bool;
      __exists : forall {a : Set}, (key -> a -> bool) -> t a -> bool;
      filter : forall {a : Set}, (key -> a -> bool) -> t a -> t a;
      partition : forall {a : Set}, (key -> a -> bool) -> t a -> t a * t a;
      cardinal : forall {a : Set}, t a -> int;
      bindings : forall {a : Set}, t a -> list (key * a);
      min_binding : forall {a : Set}, t a -> key * a;
      min_binding_opt : forall {a : Set}, t a -> option (key * a);
      max_binding : forall {a : Set}, t a -> key * a;
      max_binding_opt : forall {a : Set}, t a -> option (key * a);
      choose : forall {a : Set}, t a -> key * a;
      choose_opt : forall {a : Set}, t a -> option (key * a);
      split : forall {a : Set}, key -> t a -> t a * option a * t a;
      find : forall {a : Set}, key -> t a -> a;
      find_opt : forall {a : Set}, key -> t a -> option a;
      find_first : forall {a : Set}, (key -> bool) -> t a -> key * a;
      find_first_opt : forall {a : Set},
        (key -> bool) -> t a -> option (key * a);
      find_last : forall {a : Set}, (key -> bool) -> t a -> key * a;
      find_last_opt : forall {a : Set},
        (key -> bool) -> t a -> option (key * a);
      map : forall {a b : Set}, (a -> b) -> t a -> t b;
      mapi : forall {a b : Set}, (key -> a -> b) -> t a -> t b;
      to_seq : forall {a : Set}, t a -> OCaml.Seq.t (key * a);
      to_seq_from : forall {a : Set}, key -> t a -> OCaml.Seq.t (key * a);
      add_seq : forall {a : Set}, OCaml.Seq.t (key * a) -> t a -> t a;
      of_seq : forall {a : Set}, OCaml.Seq.t (key * a) -> t a;
      encoding : forall {a : Set}, Data_encoding.t a -> Data_encoding.t (t a);
    }.
  End INDEXES_Map.
  
  Module INDEXES.
    Record signature {t __Set_t : Set} {Map_t : Set -> Set} : Set := {
      t := t;
      to_path : t -> list string -> list string;
      of_path : list string -> option t;
      of_path_exn : list string -> t;
      prefix_path : string -> list string;
      path_length : int;
      __Set : INDEXES_Set.signature (elt := t) (t := __Set_t);
      Map : INDEXES_Map.signature (key := t) (t := Map_t);
    }.
  End INDEXES.
  
  Module HASH.
    Record signature {t __Set_t : Set} {Map_t : Set -> Set} : Set := {
      t := t;
      name : string;
      title : string;
      pp : Format.formatter -> t -> unit;
      pp_short : Format.formatter -> t -> unit;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      hash_bytes : option MBytes.t -> list MBytes.t -> t;
      hash_string : option string -> list string -> t;
      zero : t;
      size : int;
      to_bytes : t -> MBytes.t;
      of_bytes_opt : MBytes.t -> option t;
      of_bytes_exn : MBytes.t -> t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type_definition `Base58.data` *)
      b58check_encoding : Base58.encoding t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
      to_path : t -> list string -> list string;
      of_path : list string -> option t;
      of_path_exn : list string -> t;
      prefix_path : string -> list string;
      path_length : int;
      __Set : INDEXES_Set.signature (elt := t) (t := __Set_t);
      Map : INDEXES_Map.signature (key := t) (t := Map_t);
    }.
  End HASH.
  
  Module MERKLE_TREE.
    Record signature {elt t __Set_t : Set} {Map_t : Set -> Set} {path : Set}
      : Set := {
      elt := elt;
      t := t;
      name : string;
      title : string;
      pp : Format.formatter -> t -> unit;
      pp_short : Format.formatter -> t -> unit;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      hash_bytes : option MBytes.t -> list MBytes.t -> t;
      hash_string : option string -> list string -> t;
      zero : t;
      size : int;
      to_bytes : t -> MBytes.t;
      of_bytes_opt : MBytes.t -> option t;
      of_bytes_exn : MBytes.t -> t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type_definition `Base58.data` *)
      b58check_encoding : Base58.encoding t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
      to_path : t -> list string -> list string;
      of_path : list string -> option t;
      of_path_exn : list string -> t;
      prefix_path : string -> list string;
      path_length : int;
      __Set : INDEXES_Set.signature (elt := t) (t := __Set_t);
      Map : INDEXES_Map.signature (key := t) (t := Map_t);
      compute : list elt -> t;
      empty : t;
      path := path;
      compute_path : list elt -> int -> path;
      check_path : path -> elt -> t * int;
      path_encoding : Data_encoding.t path;
    }.
  End MERKLE_TREE.
  
  Module SPublic_key_hash.
    Record signature {t __Set_t : Set} {Map_t : Set -> Set} : Set := {
      t := t;
      pp : Format.formatter -> t -> unit;
      pp_short : Format.formatter -> t -> unit;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      size : int;
      to_bytes : t -> MBytes.t;
      of_bytes_opt : MBytes.t -> option t;
      of_bytes_exn : MBytes.t -> t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type_definition `Base58.data` *)
      b58check_encoding : Base58.encoding t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
      to_path : t -> list string -> list string;
      of_path : list string -> option t;
      of_path_exn : list string -> t;
      prefix_path : string -> list string;
      path_length : int;
      __Set : INDEXES_Set.signature (elt := t) (t := __Set_t);
      Map : INDEXES_Map.signature (key := t) (t := Map_t);
      zero : t;
    }.
  End SPublic_key_hash.
  
  Module SPublic_key.
    Record signature {t public_key_hash_t : Set} : Set := {
      t := t;
      pp : Format.formatter -> t -> unit;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type_definition `Base58.data` *)
      b58check_encoding : Base58.encoding t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
      public_key_hash_t := public_key_hash_t;
      __hash_value : t -> public_key_hash_t;
    }.
  End SPublic_key.
  
  Module SIGNATURE.
    Record signature {Public_key_hash_t Public_key_hash___Set_t : Set}
      {Public_key_hash_Map_t : Set -> Set} {Public_key_t t watermark : Set}
      : Set := {
      Public_key_hash :
        SPublic_key_hash.signature (t := Public_key_hash_t)
          (__Set_t := Public_key_hash___Set_t) (Map_t := Public_key_hash_Map_t);
      Public_key :
        SPublic_key.signature (t := Public_key_t)
          (public_key_hash_t := Public_key_hash.(SPublic_key_hash.t));
      t := t;
      pp : Format.formatter -> t -> unit;
      size : int;
      to_bytes : t -> MBytes.t;
      of_bytes_opt : MBytes.t -> option t;
      of_bytes_exn : MBytes.t -> t;
      op_eq : t -> t -> bool;
      op_ltgt : t -> t -> bool;
      op_lt : t -> t -> bool;
      op_lteq : t -> t -> bool;
      op_gteq : t -> t -> bool;
      op_gt : t -> t -> bool;
      compare : t -> t -> int;
      equal : t -> t -> bool;
      max : t -> t -> t;
      min : t -> t -> t;
      to_b58check : t -> string;
      to_short_b58check : t -> string;
      of_b58check_exn : string -> t;
      of_b58check_opt : string -> option t;
      (* extensible_type_definition `Base58.data` *)
      b58check_encoding : Base58.encoding t;
      encoding : Data_encoding.t t;
      rpc_arg : RPC_arg.t t;
      zero : t;
      watermark := watermark;
      check :
        option watermark -> Public_key.(SPublic_key.t) -> t -> MBytes.t -> bool;
    }.
  End SIGNATURE.
End S.

Module __Set.
  Parameter Make :
    forall (Ord : {t : Set & Compare.COMPARABLE.signature (t := t)}),
      {t : Set &
        S.SET.signature (elt := (|Ord|).(Compare.COMPARABLE.t)) (t := t)}.
End __Set.

Module Map.
  Parameter Make :
    forall (Ord : {t : Set & Compare.COMPARABLE.signature (t := t)}),
      {t : Set -> Set &
        S.MAP.signature (key := (|Ord|).(Compare.COMPARABLE.t)) (t := t)}.
End Map.

Module Blake2B.
  Module Name.
    Record signature : Set := {
      name : string;
      title : string;
      size : option int;
    }.
  End Name.
  
  Module PrefixedName.
    Record signature : Set := {
      name : string;
      title : string;
      size : option int;
      b58check_prefix : string;
    }.
  End PrefixedName.
  
  Parameter Make_minimal :
    forall (Name : {_ : unit & Name.signature}),
      {t : Set & S.MINIMAL_HASH.signature (t := t)}.
  
  Module SRegister.
    Record signature : Set := {
      register_encoding : forall {a : Set},
        string -> int -> (a -> string) -> (string -> option a) ->
        (a -> Base58.data) -> Base58.encoding a;
    }.
  End SRegister.
  
  Parameter Make :
    forall (Register : {_ : unit & SRegister.signature}),
      (forall (Name : {_ : unit & PrefixedName.signature}),
        {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
          S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}).
End Blake2B.

Parameter Ed25519 :
  {'[Public_key_hash_t, Public_key_hash___Set_t, Public_key_hash_Map_t,
    Public_key_t, t] : [Set ** Set ** Set -> Set ** Set ** Set] &
    S.SIGNATURE.signature (Public_key_hash_t := Public_key_hash_t)
      (Public_key_hash___Set_t := Public_key_hash___Set_t)
      (Public_key_hash_Map_t := Public_key_hash_Map_t)
      (Public_key_t := Public_key_t) (t := t) (watermark := MBytes.t)}.

Parameter Secp256k1 :
  {'[Public_key_hash_t, Public_key_hash___Set_t, Public_key_hash_Map_t,
    Public_key_t, t] : [Set ** Set ** Set -> Set ** Set ** Set] &
    S.SIGNATURE.signature (Public_key_hash_t := Public_key_hash_t)
      (Public_key_hash___Set_t := Public_key_hash___Set_t)
      (Public_key_hash_Map_t := Public_key_hash_Map_t)
      (Public_key_t := Public_key_t) (t := t) (watermark := MBytes.t)}.

Parameter P256 :
  {'[Public_key_hash_t, Public_key_hash___Set_t, Public_key_hash_Map_t,
    Public_key_t, t] : [Set ** Set ** Set -> Set ** Set ** Set] &
    S.SIGNATURE.signature (Public_key_hash_t := Public_key_hash_t)
      (Public_key_hash___Set_t := Public_key_hash___Set_t)
      (Public_key_hash_Map_t := Public_key_hash_Map_t)
      (Public_key_t := Public_key_t) (t := t) (watermark := MBytes.t)}.

Parameter Chain_id :
  {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
    S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}.

Module Signature.
  Parameter signature_module_tag : unit.
  
  Inductive public_key_hash : Set :=
  | Ed25519Hash :
    (|Ed25519|).(S.SIGNATURE.Public_key_hash).(S.SPublic_key_hash.t) ->
    public_key_hash
  | Secp256k1Hash :
    (|Secp256k1|).(S.SIGNATURE.Public_key_hash).(S.SPublic_key_hash.t) ->
    public_key_hash
  | P256Hash :
    (|P256|).(S.SIGNATURE.Public_key_hash).(S.SPublic_key_hash.t) ->
    public_key_hash.
  
  Inductive public_key : Set :=
  | Ed25519 :
    (|Ed25519|).(S.SIGNATURE.Public_key).(S.SPublic_key.t) -> public_key
  | Secp256k1 :
    (|Secp256k1|).(S.SIGNATURE.Public_key).(S.SPublic_key.t) -> public_key
  | P256 : (|P256|).(S.SIGNATURE.Public_key).(S.SPublic_key.t) -> public_key.
  
  Inductive watermark : Set :=
  | Block_header : (|Chain_id|).(S.HASH.t) -> watermark
  | Endorsement : (|Chain_id|).(S.HASH.t) -> watermark
  | Generic_operation : watermark
  | Custom : MBytes.t -> watermark.
  
  Parameter Included_SIGNATURE :
    {'[Public_key_hash___Set_t, Public_key_hash_Map_t, t] :
      [Set ** Set -> Set ** Set] &
      S.SIGNATURE.signature (Public_key_hash_t := public_key_hash)
        (Public_key_hash___Set_t := Public_key_hash___Set_t)
        (Public_key_hash_Map_t := Public_key_hash_Map_t)
        (Public_key_t := public_key) (t := t) (watermark := watermark)}.
  
  Definition Public_key_hash :=
    existT (fun _ => _) tt (|Included_SIGNATURE|).(S.SIGNATURE.Public_key_hash).
  
  Definition Public_key :=
    existT (fun _ => _) tt (|Included_SIGNATURE|).(S.SIGNATURE.Public_key).
  
  Definition t := (|Included_SIGNATURE|).(S.SIGNATURE.t).
  
  Definition pp : Format.formatter -> t -> unit :=
    (|Included_SIGNATURE|).(S.SIGNATURE.pp).
  
  Definition size : int := (|Included_SIGNATURE|).(S.SIGNATURE.size).
  
  Definition to_bytes : t -> MBytes.t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.to_bytes).
  
  Definition of_bytes_opt : MBytes.t -> option t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.of_bytes_opt).
  
  Definition of_bytes_exn : MBytes.t -> t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.of_bytes_exn).
  
  Definition op_eq : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_eq).
  
  Definition op_ltgt : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_ltgt).
  
  Definition op_lt : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_lt).
  
  Definition op_lteq : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_lteq).
  
  Definition op_gteq : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_gteq).
  
  Definition op_gt : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.op_gt).
  
  Definition compare : t -> t -> int :=
    (|Included_SIGNATURE|).(S.SIGNATURE.compare).
  
  Definition equal : t -> t -> bool :=
    (|Included_SIGNATURE|).(S.SIGNATURE.equal).
  
  Definition max : t -> t -> t := (|Included_SIGNATURE|).(S.SIGNATURE.max).
  
  Definition min : t -> t -> t := (|Included_SIGNATURE|).(S.SIGNATURE.min).
  
  Definition to_b58check : t -> string :=
    (|Included_SIGNATURE|).(S.SIGNATURE.to_b58check).
  
  Definition to_short_b58check : t -> string :=
    (|Included_SIGNATURE|).(S.SIGNATURE.to_short_b58check).
  
  Definition of_b58check_exn : string -> t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.of_b58check_exn).
  
  Definition of_b58check_opt : string -> option t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.of_b58check_opt).
  
  Definition b58check_encoding : Base58.encoding t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.b58check_encoding).
  
  Definition encoding : Data_encoding.t t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.encoding).
  
  Definition rpc_arg : RPC_arg.t t :=
    (|Included_SIGNATURE|).(S.SIGNATURE.rpc_arg).
  
  Definition zero : t := (|Included_SIGNATURE|).(S.SIGNATURE.zero).
  
  Definition check :
    option watermark -> (|Public_key|).(S.SPublic_key.t) -> t -> MBytes.t ->
    bool := (|Included_SIGNATURE|).(S.SIGNATURE.check).
End Signature.

Parameter Block_hash :
  {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
    S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}.

Parameter Operation_hash :
  {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
    S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}.

Parameter Operation_list_hash :
  {'[t, __Set_t, Map_t, path] : [Set ** Set ** Set -> Set ** Set] &
    S.MERKLE_TREE.signature (elt := (|Operation_hash|).(S.HASH.t)) (t := t)
      (__Set_t := __Set_t) (Map_t := Map_t) (path := path)}.

Parameter Operation_list_list_hash :
  {'[t, __Set_t, Map_t, path] : [Set ** Set ** Set -> Set ** Set] &
    S.MERKLE_TREE.signature (elt := (|Operation_list_hash|).(S.MERKLE_TREE.t))
      (t := t) (__Set_t := __Set_t) (Map_t := Map_t) (path := path)}.

Parameter Protocol_hash :
  {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
    S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}.

Parameter Context_hash :
  {'[t, __Set_t, Map_t] : [Set ** Set ** Set -> Set] &
    S.HASH.signature (t := t) (__Set_t := __Set_t) (Map_t := Map_t)}.

Module Micheline.
  Definition annot : Set := list string.
  
  Inductive node (l p : Set) : Set :=
  | Int : l -> Z.t -> node l p
  | String : l -> string -> node l p
  | Bytes : l -> MBytes.t -> node l p
  | Prim : l -> p -> list (node l p) -> annot -> node l p
  | Seq : l -> list (node l p) -> node l p.
  
  Arguments Int {_ _}.
  Arguments String {_ _}.
  Arguments Bytes {_ _}.
  Arguments Prim {_ _}.
  Arguments Seq {_ _}.
  
  Parameter canonical : forall (p : Set), Set.
  
  Definition canonical_location : Set := int.
  
  Parameter root : forall {p : Set}, canonical p -> node canonical_location p.
  
  Parameter canonical_location_encoding :
    Data_encoding.encoding canonical_location.
  
  Parameter canonical_encoding : forall {l : Set},
    string -> Data_encoding.encoding l -> Data_encoding.encoding (canonical l).
  
  Parameter canonical_encoding_v1 : forall {l : Set},
    string -> Data_encoding.encoding l -> Data_encoding.encoding (canonical l).
  
  Parameter location : forall {l p : Set}, node l p -> l.
  
  Parameter annotations : forall {l p : Set}, node l p -> list string.
  
  Parameter strip_locations : forall {A p : Set}, node A p -> canonical p.
  
  Parameter extract_locations : forall {l p : Set},
    node l p -> canonical p * list (canonical_location * l).
  
  Parameter inject_locations : forall {l p : Set},
    (canonical_location -> l) -> canonical p -> node l p.
End Micheline.

Module Block_header.
  Module shell_header.
    Record record : Set := Build {
      level : Int32.t;
      proto_level : int;
      predecessor : (|Block_hash|).(S.HASH.t);
      timestamp : Time.t;
      validation_passes : int;
      operations_hash : (|Operation_list_list_hash|).(S.MERKLE_TREE.t);
      fitness : list MBytes.t;
      context : (|Context_hash|).(S.HASH.t) }.
    Definition with_level level (r : record) :=
      Build level r.(proto_level) r.(predecessor) r.(timestamp)
        r.(validation_passes) r.(operations_hash) r.(fitness) r.(context).
    Definition with_proto_level proto_level (r : record) :=
      Build r.(level) proto_level r.(predecessor) r.(timestamp)
        r.(validation_passes) r.(operations_hash) r.(fitness) r.(context).
    Definition with_predecessor predecessor (r : record) :=
      Build r.(level) r.(proto_level) predecessor r.(timestamp)
        r.(validation_passes) r.(operations_hash) r.(fitness) r.(context).
    Definition with_timestamp timestamp (r : record) :=
      Build r.(level) r.(proto_level) r.(predecessor) timestamp
        r.(validation_passes) r.(operations_hash) r.(fitness) r.(context).
    Definition with_validation_passes validation_passes (r : record) :=
      Build r.(level) r.(proto_level) r.(predecessor) r.(timestamp)
        validation_passes r.(operations_hash) r.(fitness) r.(context).
    Definition with_operations_hash operations_hash (r : record) :=
      Build r.(level) r.(proto_level) r.(predecessor) r.(timestamp)
        r.(validation_passes) operations_hash r.(fitness) r.(context).
    Definition with_fitness fitness (r : record) :=
      Build r.(level) r.(proto_level) r.(predecessor) r.(timestamp)
        r.(validation_passes) r.(operations_hash) fitness r.(context).
    Definition with_context context (r : record) :=
      Build r.(level) r.(proto_level) r.(predecessor) r.(timestamp)
        r.(validation_passes) r.(operations_hash) r.(fitness) context.
  End shell_header.
  Definition shell_header := shell_header.record.
  
  Parameter shell_header_encoding : Data_encoding.t shell_header.
  
  Module t.
    Record record : Set := Build {
      shell : shell_header;
      protocol_data : MBytes.t }.
    Definition with_shell shell (r : record) :=
      Build shell r.(protocol_data).
    Definition with_protocol_data protocol_data (r : record) :=
      Build r.(shell) protocol_data.
  End t.
  Definition t := t.record.
  
  Parameter Included_HASHABLE :
    {_ : unit &
      S.HASHABLE.signature (t := t) (hash := (|Block_hash|).(S.HASH.t))}.
  
  Definition op_eq : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_eq).
  
  Definition op_ltgt : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_ltgt).
  
  Definition op_lt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_lt).
  
  Definition op_lteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_lteq).
  
  Definition op_gteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_gteq).
  
  Definition op_gt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_gt).
  
  Definition compare : t -> t -> int :=
    (|Included_HASHABLE|).(S.HASHABLE.compare).
  
  Definition equal : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.equal).
  
  Definition max : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.max).
  
  Definition min : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.min).
  
  Definition pp : Format.formatter -> t -> unit :=
    (|Included_HASHABLE|).(S.HASHABLE.pp).
  
  Definition encoding : Data_encoding.t t :=
    (|Included_HASHABLE|).(S.HASHABLE.encoding).
  
  Definition to_bytes : t -> MBytes.t :=
    (|Included_HASHABLE|).(S.HASHABLE.to_bytes).
  
  Definition of_bytes : MBytes.t -> option t :=
    (|Included_HASHABLE|).(S.HASHABLE.of_bytes).
  
  Definition __hash_value : t -> (|Block_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.__hash_value).
  
  Definition hash_raw : MBytes.t -> (|Block_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.hash_raw).
End Block_header.

Parameter Fitness : {_ : unit & S.T.signature (t := (list MBytes.t))}.

Module Operation.
  Module shell_header.
    Record record : Set := Build {
      branch : (|Block_hash|).(S.HASH.t) }.
    Definition with_branch branch (r : record) :=
      Build branch.
  End shell_header.
  Definition shell_header := shell_header.record.
  
  Parameter shell_header_encoding : Data_encoding.t shell_header.
  
  Module t.
    Record record : Set := Build {
      shell : shell_header;
      proto : MBytes.t }.
    Definition with_shell shell (r : record) :=
      Build shell r.(proto).
    Definition with_proto proto (r : record) :=
      Build r.(shell) proto.
  End t.
  Definition t := t.record.
  
  Parameter Included_HASHABLE :
    {_ : unit &
      S.HASHABLE.signature (t := t) (hash := (|Operation_hash|).(S.HASH.t))}.
  
  Definition op_eq : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_eq).
  
  Definition op_ltgt : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_ltgt).
  
  Definition op_lt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_lt).
  
  Definition op_lteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_lteq).
  
  Definition op_gteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_gteq).
  
  Definition op_gt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_gt).
  
  Definition compare : t -> t -> int :=
    (|Included_HASHABLE|).(S.HASHABLE.compare).
  
  Definition equal : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.equal).
  
  Definition max : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.max).
  
  Definition min : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.min).
  
  Definition pp : Format.formatter -> t -> unit :=
    (|Included_HASHABLE|).(S.HASHABLE.pp).
  
  Definition encoding : Data_encoding.t t :=
    (|Included_HASHABLE|).(S.HASHABLE.encoding).
  
  Definition to_bytes : t -> MBytes.t :=
    (|Included_HASHABLE|).(S.HASHABLE.to_bytes).
  
  Definition of_bytes : MBytes.t -> option t :=
    (|Included_HASHABLE|).(S.HASHABLE.of_bytes).
  
  Definition __hash_value : t -> (|Operation_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.__hash_value).
  
  Definition hash_raw : MBytes.t -> (|Operation_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.hash_raw).
End Operation.

Module Protocol.
  Module t.
    Record record {expected_env components : Set} : Set := Build {
      expected_env : expected_env;
      components : components }.
    Arguments record : clear implicits.
    Definition with_expected_env {t_expected_env t_components} expected_env
      (r : record t_expected_env t_components) :=
      Build t_expected_env t_components expected_env r.(components).
    Definition with_components {t_expected_env t_components} components
      (r : record t_expected_env t_components) :=
      Build t_expected_env t_components r.(expected_env) components.
  End t.
  Definition t_skeleton := t.record.
  
  Module component.
    Record record {name interface implementation : Set} : Set := Build {
      name : name;
      interface : interface;
      implementation : implementation }.
    Arguments record : clear implicits.
    Definition with_name {t_name t_interface t_implementation} name
      (r : record t_name t_interface t_implementation) :=
      Build t_name t_interface t_implementation name r.(interface)
        r.(implementation).
    Definition with_interface {t_name t_interface t_implementation} interface
      (r : record t_name t_interface t_implementation) :=
      Build t_name t_interface t_implementation r.(name) interface
        r.(implementation).
    Definition with_implementation {t_name t_interface t_implementation}
      implementation (r : record t_name t_interface t_implementation) :=
      Build t_name t_interface t_implementation r.(name) r.(interface)
        implementation.
  End component.
  Definition component_skeleton := component.record.
  
  Reserved Notation "'component".
  Reserved Notation "'t".
  
  Inductive env_version : Set :=
  | V1 : env_version
  
  where "'component" := (component_skeleton string (option string) string)
  and "'t" := (t_skeleton env_version (list 'component)).
  
  Definition component := 'component.
  Definition t := 't.
  
  Parameter component_encoding : Data_encoding.t component.
  
  Parameter env_version_encoding : Data_encoding.t env_version.
  
  Parameter Included_HASHABLE :
    {_ : unit &
      S.HASHABLE.signature (t := t) (hash := (|Protocol_hash|).(S.HASH.t))}.
  
  Definition op_eq : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_eq).
  
  Definition op_ltgt : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_ltgt).
  
  Definition op_lt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_lt).
  
  Definition op_lteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_lteq).
  
  Definition op_gteq : t -> t -> bool :=
    (|Included_HASHABLE|).(S.HASHABLE.op_gteq).
  
  Definition op_gt : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.op_gt).
  
  Definition compare : t -> t -> int :=
    (|Included_HASHABLE|).(S.HASHABLE.compare).
  
  Definition equal : t -> t -> bool := (|Included_HASHABLE|).(S.HASHABLE.equal).
  
  Definition max : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.max).
  
  Definition min : t -> t -> t := (|Included_HASHABLE|).(S.HASHABLE.min).
  
  Definition pp : Format.formatter -> t -> unit :=
    (|Included_HASHABLE|).(S.HASHABLE.pp).
  
  Definition encoding : Data_encoding.t t :=
    (|Included_HASHABLE|).(S.HASHABLE.encoding).
  
  Definition to_bytes : t -> MBytes.t :=
    (|Included_HASHABLE|).(S.HASHABLE.to_bytes).
  
  Definition of_bytes : MBytes.t -> option t :=
    (|Included_HASHABLE|).(S.HASHABLE.of_bytes).
  
  Definition __hash_value : t -> (|Protocol_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.__hash_value).
  
  Definition hash_raw : MBytes.t -> (|Protocol_hash|).(S.HASH.t) :=
    (|Included_HASHABLE|).(S.HASHABLE.hash_raw).
End Protocol.

Module Context.
  Parameter t : Set.
  
  Definition key : Set := list string.
  
  Definition value : Set := MBytes.t.
  
  Parameter mem : t -> key -> Lwt.t bool.
  
  Parameter dir_mem : t -> key -> Lwt.t bool.
  
  Parameter get : t -> key -> Lwt.t (option value).
  
  Parameter set : t -> key -> value -> Lwt.t t.
  
  Parameter copy : t -> key -> key -> Lwt.t (option t).
  
  Parameter del : t -> key -> Lwt.t t.
  
  Parameter remove_rec : t -> key -> Lwt.t t.
  
  Inductive dir_or_key : Set :=
  | Dir : key -> dir_or_key
  | Key : key -> dir_or_key.
  
  Parameter fold : forall {a : Set},
    t -> key -> a -> (Context.dir_or_key -> a -> Lwt.t a) -> Lwt.t a.
  
  Parameter keys : t -> key -> Lwt.t (list key).
  
  Parameter fold_keys : forall {a : Set},
    t -> key -> a -> (key -> a -> Lwt.t a) -> Lwt.t a.
  
  Parameter register_resolver : forall {a : Set},
    Base58.encoding a -> (t -> string -> Lwt.t (list a)) -> unit.
  
  Parameter complete : t -> string -> Lwt.t (list string).
End Context.

Module Updater.
  Module validation_result.
    Record record : Set := Build {
      context : Context.t;
      fitness : (|Fitness|).(S.T.t);
      message : option string;
      max_operations_ttl : int;
      last_allowed_fork_level : Int32.t }.
    Definition with_context context (r : record) :=
      Build context r.(fitness) r.(message) r.(max_operations_ttl)
        r.(last_allowed_fork_level).
    Definition with_fitness fitness (r : record) :=
      Build r.(context) fitness r.(message) r.(max_operations_ttl)
        r.(last_allowed_fork_level).
    Definition with_message message (r : record) :=
      Build r.(context) r.(fitness) message r.(max_operations_ttl)
        r.(last_allowed_fork_level).
    Definition with_max_operations_ttl max_operations_ttl (r : record) :=
      Build r.(context) r.(fitness) r.(message) max_operations_ttl
        r.(last_allowed_fork_level).
    Definition with_last_allowed_fork_level last_allowed_fork_level
      (r : record) :=
      Build r.(context) r.(fitness) r.(message) r.(max_operations_ttl)
        last_allowed_fork_level.
  End validation_result.
  Definition validation_result := validation_result.record.
  
  Module quota.
    Record record : Set := Build {
      max_size : int;
      max_op : option int }.
    Definition with_max_size max_size (r : record) :=
      Build max_size r.(max_op).
    Definition with_max_op max_op (r : record) :=
      Build r.(max_size) max_op.
  End quota.
  Definition quota := quota.record.
  
  Module rpc_context.
    Record record : Set := Build {
      block_hash : (|Block_hash|).(S.HASH.t);
      block_header : Block_header.shell_header;
      context : Context.t }.
    Definition with_block_hash block_hash (r : record) :=
      Build block_hash r.(block_header) r.(context).
    Definition with_block_header block_header (r : record) :=
      Build r.(block_hash) block_header r.(context).
    Definition with_context context (r : record) :=
      Build r.(block_hash) r.(block_header) context.
  End rpc_context.
  Definition rpc_context := rpc_context.record.
  
  Module PROTOCOL.
    Record signature {block_header_data block_header block_header_metadata
      operation_data operation_receipt operation validation_state : Set} : Set
      := {
      max_block_length : int;
      max_operation_data_length : int;
      validation_passes : list quota;
      block_header_data := block_header_data;
      block_header_data_encoding : Data_encoding.t block_header_data;
      block_header := block_header;
      block_header_metadata := block_header_metadata;
      block_header_metadata_encoding : Data_encoding.t block_header_metadata;
      operation_data := operation_data;
      operation_receipt := operation_receipt;
      operation := operation;
      operation_data_encoding : Data_encoding.t operation_data;
      operation_receipt_encoding : Data_encoding.t operation_receipt;
      operation_data_and_receipt_encoding :
        Data_encoding.t (operation_data * operation_receipt);
      acceptable_passes : operation -> list int;
      compare_operations : operation -> operation -> int;
      validation_state := validation_state;
      current_context :
        validation_state -> Lwt.t (Error_monad.tzresult Context.t);
      begin_partial_application :
        (|Chain_id|).(S.HASH.t) -> Context.t -> Time.t -> (|Fitness|).(S.T.t) ->
        block_header -> Lwt.t (Error_monad.tzresult validation_state);
      begin_application :
        (|Chain_id|).(S.HASH.t) -> Context.t -> Time.t -> (|Fitness|).(S.T.t) ->
        block_header -> Lwt.t (Error_monad.tzresult validation_state);
      begin_construction :
        (|Chain_id|).(S.HASH.t) -> Context.t -> Time.t -> Int32.t ->
        (|Fitness|).(S.T.t) -> (|Block_hash|).(S.HASH.t) -> Time.t ->
        option block_header_data -> unit ->
        Lwt.t (Error_monad.tzresult validation_state);
      apply_operation :
        validation_state -> operation ->
        Lwt.t (Error_monad.tzresult (validation_state * operation_receipt));
      finalize_block :
        validation_state ->
        Lwt.t (Error_monad.tzresult (validation_result * block_header_metadata));
      rpc_services : RPC_directory.t rpc_context;
      init :
        Context.t -> Block_header.shell_header ->
        Lwt.t (Error_monad.tzresult validation_result);
    }.
  End PROTOCOL.
  
  Parameter activate :
    Context.t -> (|Protocol_hash|).(S.HASH.t) -> Lwt.t Context.t.
  
  Parameter fork_test_chain :
    Context.t -> (|Protocol_hash|).(S.HASH.t) -> Time.t -> Lwt.t Context.t.
End Updater.

Module RPC_context.
  Definition t : Set := Updater.rpc_context.
  
  Module simple.
    Record record {pr : Set} : Set := Build {
      call_proto_service0 :
        forall {q i o : Set},
          RPC_service.t t t q i o -> pr -> q -> i ->
          Lwt.t (Error_monad.shell_tzresult o);
      call_proto_service1 :
        forall {a q i o : Set},
          RPC_service.t t (t * a) q i o -> pr -> a -> q -> i ->
          Lwt.t (Error_monad.shell_tzresult o);
      call_proto_service2 :
        forall {a b q i o : Set},
          RPC_service.t t ((t * a) * b) q i o -> pr -> a -> b -> q -> i ->
          Lwt.t (Error_monad.shell_tzresult o);
      call_proto_service3 :
        forall {a b c q i o : Set},
          RPC_service.t t (((t * a) * b) * c) q i o -> pr -> a -> b -> c -> q ->
          i -> Lwt.t (Error_monad.shell_tzresult o) }.
    Arguments record : clear implicits.
  End simple.
  Definition simple := simple.record.
  
  Parameter make_call0 : forall {i o pr q : Set},
    RPC_service.t t t q i o -> simple pr -> pr -> q -> i ->
    Lwt.t (Error_monad.shell_tzresult o).
  
  Parameter make_call1 : forall {a i o pr q : Set},
    RPC_service.t t (t * a) q i o -> simple pr -> pr -> a -> q -> i ->
    Lwt.t (Error_monad.shell_tzresult o).
  
  Parameter make_call2 : forall {a b i o pr q : Set},
    RPC_service.t t ((t * a) * b) q i o -> simple pr -> pr -> a -> b -> q ->
    i -> Lwt.t (Error_monad.shell_tzresult o).
  
  Parameter make_call3 : forall {a b c i o pr q : Set},
    RPC_service.t t (((t * a) * b) * c) q i o -> simple pr -> pr -> a -> b ->
    c -> q -> i -> Lwt.t (Error_monad.shell_tzresult o).
  
  Parameter make_opt_call0 : forall {i o pr q : Set},
    RPC_service.t t t q i o -> simple pr -> pr -> q -> i ->
    Lwt.t (Error_monad.shell_tzresult (option o)).
  
  Parameter make_opt_call1 : forall {a i o pr q : Set},
    RPC_service.t t (t * a) q i o -> simple pr -> pr -> a -> q -> i ->
    Lwt.t (Error_monad.shell_tzresult (option o)).
  
  Parameter make_opt_call2 : forall {a b i o pr q : Set},
    RPC_service.t t ((t * a) * b) q i o -> simple pr -> pr -> a -> b -> q ->
    i -> Lwt.t (Error_monad.shell_tzresult (option o)).
  
  Parameter make_opt_call3 : forall {a b c i o pr q : Set},
    RPC_service.t t (((t * a) * b) * c) q i o -> simple pr -> pr -> a -> b ->
    c -> q -> i -> Lwt.t (Error_monad.shell_tzresult (option o)).
End RPC_context.

Module Notations.
  Notation "'let=' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgteq X (fun x => Y))
    (at level 200, x ident, X at level 100, Y at level 200).

  Notation "'let=' ' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgteq X (fun x => Y))
    (at level 200, x pattern, X at level 100, Y at level 200).

  Notation "'let=?' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgteqquestion X (fun x => Y))
    (at level 200, x ident, X at level 100, Y at level 200).

  Notation "'let=?' ' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgteqquestion X (fun x => Y))
    (at level 200, x pattern, X at level 100, Y at level 200).

  Notation "'let?' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgtquestion X (fun x => Y))
    (at level 200, x ident, X at level 100, Y at level 200).

  Notation "'let?' ' x ':=' X 'in' Y" :=
    (Error_monad.op_gtgtquestion X (fun x => Y))
    (at level 200, x pattern, X at level 100, Y at level 200).
End Notations.