123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960open!Basetype'at={g:'a}[@@unboxed](* We want to ensure the derived operations are exactly the same as for the inner type, so
we define them directly. *)let[@inline]createg={g}let[@inline]g{g}=glet[@inline]map{g}~f={g=fg}let[@inline]comparecompare_g{g=a}{g=b}=compare_gablet[@inline]hash_fold_thash_fold_ghash_state{g}=hash_fold_ghash_stateglet[@inline]sexp_of_tsexp_of_g{g}=sexp_of_gglet[@inline]t_of_sexpg_of_sexpsexp={g=g_of_sexpsexp}let[@inline]globalize_{g}={g}let[@inline]equalequal_g{g=a}{g=b}=equal_gab(* Proof that [drop_some] can be safely implemented in normal ocaml. But this
implementation allocates a second option locally. *)let_drop_some_proof:'atoption->'aoption=funx->matchxwith|None->None|Some{g}->Someg;;(* This version of [drop_some] does not. *)externaldrop_some:'atoption->'aoption="%identity"(* A similar argument applies to [drop_ok] and [drop_error]. *)externaldrop_ok:('at,'b)Result.t->('a,'b)Result.t="%identity"externaldrop_error:('a,'bt)Result.t->('a,'b)Result.t="%identity"(* Proof that [inject_some] can be safely implemented in normal ocaml. But this
implementation allocates a second option locally. *)let_inject_some:'aoption->'atoption=funx->matchxwith|None->None|Somey->Some{g=y};;externalinject_some:'aoption->'atoption="%identity"externalinject_ok:('a,'b)Result.t->('at,'b)Result.t="%identity"externalinject_error:('a,'b)Result.t->('a,'bt)Result.t="%identity"externalinject_result:('a,'b)Result.t->('at,'bt)Result.t="%identity"(* We specifically use the "legacy" [Make_binable1_without_uuid] function, because it
_doesn't_ change the bin_io shape, which is what we want here. *)includeBin_prot.Utils.Make_binable1_without_uuid[@alert"-legacy"][@inlinedhint](structmoduleBinable=structtype'at='a[@@derivingbin_io]endtypenonrec'at='atlet[@inline]of_binableg={g}let[@inline]to_binable{g}=gend)