123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.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. *)(* *)(*****************************************************************************)(** We have to duplicate the content of
[src/lib_protocol_environment/sigs/v3/set.mli] (and a few other signatures
from the same directory) so we can refer to them in
[src/lib_protocol_environment/environment_V3.ml]. Indeed, it is impossible
to refer to components of [Tezos_protocol_environment_sigs.V3.T] (such as
the [Set] component) because [T] is a module type (not a module).
It might be possible to change the way that the signatures are exported and
thus allow access to some of the sub-components, at which point this whole
file can be removed. Note, however, that some components make reference to
others (e.g., here we need to introduce the type [error_monad_trace] which
we then substitute for [Error_monad.trace]) so simply exporting the
components will not suffice because there will be unbound types.
Ultimately, it might be easier to provide each struct as a partial or full
set of legacy libraries which used to be present at the time the environment
was made. For the signatures below, we would include a full implementation
of [Lwtreslib] as it appeared when the environment v3 was cut. *)moduleCompare=structmoduletypeCOMPARABLE=sigtypetvalcompare:t->t->intendendmoduleSet=structmoduletypeS=sigtype'aerror_monad_trace(* to be substituted *)typeelttypetvalempty:tvalis_empty:t->boolvalmem:elt->t->boolvaladd:elt->t->tvalsingleton:elt->tvalremove:elt->t->tvalunion:t->t->tvalinter:t->t->tvaldisjoint:t->t->boolvaldiff:t->t->tvalcompare:t->t->intvalequal:t->t->boolvalsubset:t->t->boolvaliter:(elt->unit)->t->unitvaliter_e:(elt->(unit,'trace)result)->t->(unit,'trace)resultvaliter_s:(elt->unitLwt.t)->t->unitLwt.tvaliter_p:(elt->unitLwt.t)->t->unitLwt.tvaliter_es:(elt->(unit,'trace)resultLwt.t)->t->(unit,'trace)resultLwt.tvalmap:(elt->elt)->t->tvalfold:(elt->'a->'a)->t->'a->'avalfold_e:(elt->'a->('a,'trace)result)->t->'a->('a,'trace)resultvalfold_s:(elt->'a->'aLwt.t)->t->'a->'aLwt.tvalfold_es:(elt->'a->('a,'trace)resultLwt.t)->t->'a->('a,'trace)resultLwt.tvalfor_all:(elt->bool)->t->boolvalexists:(elt->bool)->t->boolvalfilter:(elt->bool)->t->tvalpartition:(elt->bool)->t->t*tvalcardinal:t->intvalelements:t->eltlistvalmin_elt:t->eltoptionvalmax_elt:t->eltoptionvalchoose:t->eltoptionvalsplit:elt->t->t*bool*tvalfind:elt->t->eltoptionvalfind_first:(elt->bool)->t->eltoptionvalfind_last:(elt->bool)->t->eltoptionvalof_list:eltlist->tvalto_seq_from:elt->t->eltStdlib.Seq.tvalto_seq:t->eltStdlib.Seq.tvaladd_seq:eltStdlib.Seq.t->t->tvalof_seq:eltStdlib.Seq.t->tvaliter_ep:(elt->(unit,'errorerror_monad_trace)resultLwt.t)->t->(unit,'errorerror_monad_trace)resultLwt.tendendmoduleMap=structmoduletypeS=sigtype'aerror_monad_trace(* for substitution *)typekeytype+!'atvalempty:'atvalis_empty:'at->boolvalmem:key->'at->boolvaladd:key->'a->'at->'atvalupdate:key->('aoption->'aoption)->'at->'atvalsingleton:key->'a->'atvalremove:key->'at->'atvalmerge:(key->'aoption->'boption->'coption)->'at->'bt->'ctvalunion:(key->'a->'a->'aoption)->'at->'at->'atvalcompare:('a->'a->int)->'at->'at->intvalequal:('a->'a->bool)->'at->'at->boolvaliter:(key->'a->unit)->'at->unit(** [iter_e f m] applies [f] to the bindings of [m] one by one in an
unspecified order. If all the applications result in [Ok ()], then the
result of the iteration is [Ok ()]. If any of the applications results in
[Error e] then the iteration stops and the result of the iteration is
[Error e]. *)valiter_e:(key->'a->(unit,'trace)result)->'at->(unit,'trace)resultvaliter_s:(key->'a->unitLwt.t)->'at->unitLwt.tvaliter_p:(key->'a->unitLwt.t)->'at->unitLwt.t(** [iter_es f m] applies [f] to the bindings of [m] in an unspecified order,
one after the other as the promises resolve. If all the applications
result in [Ok ()], then the result of the iteration is [Ok ()]. If any of
the applications results in [Error e] then the iteration stops and the
result of the iteration is [Error e]. *)valiter_es:(key->'a->(unit,'trace)resultLwt.t)->'at->(unit,'trace)resultLwt.tvalfold:(key->'a->'b->'b)->'at->'b->'b(** [fold_e f m init] is
[f k1 d1 init >>? fun acc -> f k2 d2 acc >>? fun acc -> …] where [kN] is
the key bound to [dN] in [m]. *)valfold_e:(key->'a->'b->('b,'trace)result)->'at->'b->('b,'trace)resultvalfold_s:(key->'a->'b->'bLwt.t)->'at->'b->'bLwt.t(** [fold_es f m init] is
[f k1 d1 init >>=? fun acc -> f k2 d2 acc >>=? fun acc -> …] where [kN] is
the key bound to [dN] in [m]. *)valfold_es:(key->'a->'b->('b,'trace)resultLwt.t)->'at->'b->('b,'trace)resultLwt.tvalfor_all:(key->'a->bool)->'at->boolvalexists:(key->'a->bool)->'at->boolvalfilter:(key->'a->bool)->'at->'atvalpartition:(key->'a->bool)->'at->'at*'atvalcardinal:'at->intvalbindings:'at->(key*'a)listvalmin_binding:'at->(key*'a)optionvalmax_binding:'at->(key*'a)optionvalchoose:'at->(key*'a)optionvalsplit:key->'at->'at*'aoption*'atvalfind:key->'at->'aoptionvalfind_first:(key->bool)->'at->(key*'a)optionvalfind_last:(key->bool)->'at->(key*'a)optionvalmap:('a->'b)->'at->'btvalmapi:(key->'a->'b)->'at->'btvalto_seq:'at->(key*'a)Seq.tvalto_seq_from:key->'at->(key*'a)Seq.tvaladd_seq:(key*'a)Seq.t->'at->'atvalof_seq:(key*'a)Seq.t->'atvaliter_ep:(key->'a->(unit,'errorerror_monad_trace)resultLwt.t)->'at->(unit,'errorerror_monad_trace)resultLwt.tendend