Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file sign_or_nan.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128open!ImportmoduleT=structtypet=|Neg|Zero|Pos|Nan[@@deriving_inlinesexp,compare,hash,enumerate]lett_of_sexp=(let_tp_loc="sign_or_nan.ml.T.t"infunction|Ppx_sexp_conv_lib.Sexp.Atom("neg"|"Neg")->Neg|Ppx_sexp_conv_lib.Sexp.Atom("zero"|"Zero")->Zero|Ppx_sexp_conv_lib.Sexp.Atom("pos"|"Pos")->Pos|Ppx_sexp_conv_lib.Sexp.Atom("nan"|"Nan")->Nan|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom("neg"|"Neg")::_)assexp->Ppx_sexp_conv_lib.Conv_error.stag_no_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom("zero"|"Zero")::_)assexp->Ppx_sexp_conv_lib.Conv_error.stag_no_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom("pos"|"Pos")::_)assexp->Ppx_sexp_conv_lib.Conv_error.stag_no_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.Atom("nan"|"Nan")::_)assexp->Ppx_sexp_conv_lib.Conv_error.stag_no_args_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List(Ppx_sexp_conv_lib.Sexp.List_::_)assexp->Ppx_sexp_conv_lib.Conv_error.nested_list_invalid_sum_tp_locsexp|Ppx_sexp_conv_lib.Sexp.List[]assexp->Ppx_sexp_conv_lib.Conv_error.empty_list_invalid_sum_tp_locsexp|sexp->Ppx_sexp_conv_lib.Conv_error.unexpected_stag_tp_locsexp:Ppx_sexp_conv_lib.Sexp.t->t);;letsexp_of_t=(function|Neg->Ppx_sexp_conv_lib.Sexp.Atom"Neg"|Zero->Ppx_sexp_conv_lib.Sexp.Atom"Zero"|Pos->Ppx_sexp_conv_lib.Sexp.Atom"Pos"|Nan->Ppx_sexp_conv_lib.Sexp.Atom"Nan":t->Ppx_sexp_conv_lib.Sexp.t);;letcompare=(Ppx_compare_lib.polymorphic_compare:t->t->int)let(hash_fold_t:Ppx_hash_lib.Std.Hash.state->t->Ppx_hash_lib.Std.Hash.state)=(funhsvarg->matchargwith|Neg->Ppx_hash_lib.Std.Hash.fold_inthsv0|Zero->Ppx_hash_lib.Std.Hash.fold_inthsv1|Pos->Ppx_hash_lib.Std.Hash.fold_inthsv2|Nan->Ppx_hash_lib.Std.Hash.fold_inthsv3:Ppx_hash_lib.Std.Hash.state->t->Ppx_hash_lib.Std.Hash.state);;let(hash:t->Ppx_hash_lib.Std.Hash.hash_value)=letfuncarg=Ppx_hash_lib.Std.Hash.get_hash_value(lethsv=Ppx_hash_lib.Std.Hash.create()inhash_fold_thsvarg)infunx->funcx;;letall=([Neg;Zero;Pos;Nan]:tlist)[@@@end]letof_strings=t_of_sexp(sexp_of_strings)letto_stringt=string_of_sexp(sexp_of_tt)letmodule_name="Base.Sign_or_nan"endmoduleReplace_polymorphic_compare=structlet(<)(x:T.t)y=Poly.(<)xylet(<=)(x:T.t)y=Poly.(<=)xylet(<>)(x:T.t)y=Poly.(<>)xylet(=)(x:T.t)y=Poly.(=)xylet(>)(x:T.t)y=Poly.(>)xylet(>=)(x:T.t)y=Poly.(>=)xyletascending(x:T.t)y=Poly.ascendingxyletdescending(x:T.t)y=Poly.descendingxyletcompare(x:T.t)y=Poly.comparexyletequal(x:T.t)y=Poly.equalxyletmax(x:T.t)y=ifx>=ythenxelseyletmin(x:T.t)y=ifx<=ythenxelseyendincludeTincludeIdentifiable.Make(T)(* Open [Replace_polymorphic_compare] after including functor applications so they do not
shadow its definitions. This is here so that efficient versions of the comparison
functions are available within this module. *)open!Replace_polymorphic_compareletof_sign=function|Sign.Neg->Neg|Sign.Zero->Zero|Sign.Pos->Pos;;letto_sign_exn=function|Neg->Sign.Neg|Zero->Sign.Zero|Pos->Sign.Pos|Nan->invalid_arg"Base.Sign_or_nan.to_sign_exn: Nan";;letof_intn=of_sign(Sign.of_intn)letto_int_exnt=Sign.to_int(to_sign_exnt)letflip=function|Neg->Pos|Zero->Zero|Pos->Neg|Nan->Nan;;let(*)tt'=matcht,t'with|Nan,_|_,Nan->Nan|_->of_sign(Sign.(*)(to_sign_exnt)(to_sign_exnt'));;(* Include [Replace_polymorphic_compare] at the end, after any functor applications that
could shadow its definitions. This is here so that efficient versions of the comparison
functions are exported by this module. *)includeReplace_polymorphic_compare