12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(* This is broken off to avoid circular dependency between Sign and Comparable. *)open!Importtypet=|Neg|Zero|Pos[@@deriving_inlinesexp,compare,hash,enumerate]lett_of_sexp=(let_tp_loc="src/sign0.ml.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.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.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":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)=(funhsv->funarg->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: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->funcxletall=([Neg;Zero;Pos]:tlist)[@@@end]moduleReplace_polymorphic_compare=structlet(<)(x:t)y=Poly.(<)xylet(<=)(x:t)y=Poly.(<=)xylet(<>)(x:t)y=Poly.(<>)xylet(=)(x:t)y=Poly.(=)xylet(>)(x:t)y=Poly.(>)xylet(>=)(x:t)y=Poly.(>=)xyletascending(x:t)y=Poly.ascendingxyletdescending(x:t)y=Poly.descendingxyletcompare(x:t)y=Poly.comparexyletequal(x:t)y=Poly.equalxyletmax(x:t)y=ifx>=ythenxelseyletmin(x:t)y=ifx<=ythenxelseyendletof_strings=t_of_sexp(sexp_of_strings)letto_stringt=string_of_sexp(sexp_of_tt)letto_int=function|Neg->-1|Zero->0|Pos->1;;let_=hash(* Ignore the hash function produced by [@@deriving_inline hash][@@@end] *)lethash=to_intletmodule_name="Base.Sign"letof_intn=ifn<0thenNegelseifn=0thenZeroelsePos