If sexp_of_t fails
, it returns Error
rather than raising. You can convert values
of this type to and from sexp in processes that can or cannot parse the underlying
sexp in any combination and still recover the original value. Also, the Error
case
contains a human-readable description of the error.
A common use case is to parse most of a sexp even when some small part fails to parse, e.g.:
type query =
| Start of Initial_config.t Sexp_maybe.t
| Stop of Reason_to_stop.t Sexp_maybe.t
[@@deriving sexp]
If Reason_to_stop.t_of_sexp
fails, you can still tell it was a Stop
query.
include sig ... end
val t_of_sexp : (Sexplib.Sexp.t ‑> 'a) ‑> Sexplib.Sexp.t ‑> 'a t
val sexp_of_t : ('a ‑> Sexplib.Sexp.t) ‑> 'a t ‑> Sexplib.Sexp.t
val hash_fold_t : (Ppx_hash_lib.Std.Hash.state ‑> 'a ‑> Ppx_hash_lib.Std.Hash.state) ‑> Ppx_hash_lib.Std.Hash.state ‑> 'a t ‑> Ppx_hash_lib.Std.Hash.state
val compare : ('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> 'a t ‑> 'a t ‑> Core_kernel__.Import.int
val bin_t : 'a Bin_prot.Type_class.t ‑> 'a t Bin_prot.Type_class.t
val bin_read_t : 'a Bin_prot.Read.reader ‑> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader ‑> (Core_kernel__.Import.int ‑> 'a t) Bin_prot.Read.reader
val bin_reader_t : 'a Bin_prot.Type_class.reader ‑> 'a t Bin_prot.Type_class.reader
val bin_size_t : 'a Bin_prot.Size.sizer ‑> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Write.writer ‑> 'a t Bin_prot.Write.writer
val bin_writer_t : 'a Bin_prot.Type_class.writer ‑> 'a t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t ‑> Bin_prot.Shape.t