123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107open!Importletinvalid_argf=Printf.invalid_argfmoduleT=structtypet=bool[@@deriving_inlinecompare,enumerate,hash,sexp,sexp_grammar]letcompare=(compare_bool:t->t->int)letall=([false;true]:tlist)let(hash_fold_t:Ppx_hash_lib.Std.Hash.state->t->Ppx_hash_lib.Std.Hash.state)=hash_fold_booland(hash:t->Ppx_hash_lib.Std.Hash.hash_value)=letfunc=hash_boolinfunx->funcx;;lett_of_sexp=(bool_of_sexp:Ppx_sexp_conv_lib.Sexp.t->t)letsexp_of_t=(sexp_of_bool:t->Ppx_sexp_conv_lib.Sexp.t)let(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=let(_the_generic_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.generic_group)={implicit_vars=["bool"];ggid="\146e\023\249\235eE\139c\132W\195\137\129\235\025";types=["t",Implicit_var0]}inlet(_the_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.group)={gid=Ppx_sexp_conv_lib.Lazy_group_id.create();apply_implicit=[bool_sexp_grammar];generic_group=_the_generic_group;origin="bool.ml.T"}inlet(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=Ref("t",_the_group)int_sexp_grammar;;[@@@end]letof_string=function|"true"->true|"false"->false|s->invalid_argf"Bool.of_string: expected true or false but got %s"s();;letto_string=Caml.string_of_boolendincludeTincludeComparator.Make(T)includeComparable.Validate(T)includePretty_printer.Register(structtypenonrect=tletto_string=to_stringletmodule_name="Base.Bool"end)(* Open replace_polymorphic_compare after including functor instantiations so they do not
shadow its definitions. This is here so that efficient versions of the comparison
functions are available within this module. *)open!Bool_replace_polymorphic_compareletinvariant(_:t)=()letbetweent~low~high=low<=t&&t<=highletclamp_uncheckedt~min~max=ift<minthenminelseift<=maxthentelsemaxletclamp_exnt~min~max=assert(min<=max);clamp_uncheckedt~min~max;;letclampt~min~max=ifmin>maxthenOr_error.error_s(Sexp.message"clamp requires [min <= max]"["min",T.sexp_of_tmin;"max",T.sexp_of_tmax])elseOk(clamp_uncheckedt~min~max);;letto_intx=bool_to_intxmoduleNon_short_circuiting=struct(* We don't expose this, since we don't want to break the invariant mentioned below of
(to_int true = 1) and (to_int false = 0). *)letunsafe_of_int(x:int):bool=Caml.Obj.magicxlet(||)ab=unsafe_of_int(to_intalorto_intb)let(&&)ab=unsafe_of_int(to_intalandto_intb)end(* We do this as a direct assert on the theory that it's a cheap thing to test and a
really core invariant that we never expect to break, and we should be happy for a
program to fail immediately if this is violated. *)let()=assert(Poly.(=)(to_inttrue)1&&Poly.(=)(to_intfalse)0)(* Include type-specific [Replace_polymorphic_compare] at the end, after
including functor application that could shadow its definitions. This is
here so that efficient versions of the comparison functions are exported by
this module. *)includeBool_replace_polymorphic_compare