package core

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

Module V1.Bin_shape_same_as_floatSource

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.

Sourcetype nonrec t = t
include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval 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
Sourceval bin_size_t : t Bin_prot.Size.sizer
Sourceval bin_write_t : t Bin_prot.Write.writer
Sourceval bin_read_t : t Bin_prot.Read.reader
Sourceval __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.

Sourceval bin_shape_t : Bin_prot.Shape.t
include Ppx_compare_lib.Comparable.S with type t := t
Sourceval compare : t -> t -> int
Sourceval globalize : t -> t
include Ppx_hash_lib.Hashable.S with type t := t
Sourceval hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
include Ppx_compare_lib.Equal.S with type t := t
Sourceval equal : t -> t -> bool
Sourceval stable_witness : t Ppx_stable_witness_runtime.Stable_witness.t
Sourcemodule Diff : sig ... end