package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Tl;dr: For new code use Stable.V3 if you care about exact round-trippability via sexp, or Almost_round_trippable if you want to round your output to 14 significant digits to hide common floating-point rounding errors and make it less of an eyesore but also less accurate.

The difference between V3 and V2 is that V3 sexp (de)serialization is fully round-trippable. There is no difference in bin_io between V2 and V3, and they have identical bin_shape.

V1 and V2 sexp serialization rounds to 6 significant digits, and serialization / deserialization go through an extra float multiplication / divison in the % or bp case. This may cause further loss of precision, which is the reason why V1's or V2's t_of_sexp may be slightly off even when reading V3-generated sexps.

If one wants to stick to the 6 significant digits in the sexp output, it is still recommended to use V2 over V1:

V1.Bin_shape_same_as_float.t's sexp and bin-io representations are the same as V2.t's. There are only two differences:

  • V2 has a distinct bin_shape_t from Float.bin_shape_t, to suggest that changing a protocol type from a percent to a float (or vice-versa) is a breaking change, semantically.
  • V2.{Map,Set}.t_of_sexp no longer accept keys/elements formatted as floats rather than as Percents.

Usually existing code can upgrade in-place from V1.Bin_shape_same_as_float to V2, as long as no client code uses bin_shape_t dynamically.

type nonrec t = t
include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val t_sexp_grammar : t Sexplib0.Sexp_grammar.t
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader

This function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.

val bin_shape_t : Bin_prot.Shape.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
include Ppx_compare_lib.Comparable.S with type t := t
val compare : t -> t -> int
include Ppx_hash_lib.Hashable.S with type t := t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
include Ppx_compare_lib.Equal.S with type t := t
val equal : t -> t -> bool
include Typerep_lib.Typerepable.S with type t := t
val typename_of_t : t Typerep_lib.Typename.t