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 ... endval bin_t : 'a Bin_prot.Type_class.t ‑> 'a t Bin_prot.Type_class.tval bin_read_t : 'a Bin_prot.Read.reader ‑> 'a t Bin_prot.Read.readerval __bin_read_t__ : 'a Bin_prot.Read.reader ‑> (Core_kernel__.Import.int ‑> 'a t) Bin_prot.Read.readerval bin_reader_t : 'a Bin_prot.Type_class.reader ‑> 'a t Bin_prot.Type_class.readerval bin_size_t : 'a Bin_prot.Size.sizer ‑> 'a t Bin_prot.Size.sizerval bin_write_t : 'a Bin_prot.Write.writer ‑> 'a t Bin_prot.Write.writerval bin_writer_t : 'a Bin_prot.Type_class.writer ‑> 'a t Bin_prot.Type_class.writerval bin_shape_t : Bin_prot.Shape.t ‑> Bin_prot.Shape.tval compare : ('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> 'a t ‑> 'a t ‑> Core_kernel__.Import.intval hash_fold_t : (Base.Hash.state ‑> 'a ‑> Base.Hash.state) ‑> Base.Hash.state ‑> 'a t ‑> Base.Hash.stateval t_of_sexp : (Base.Sexp.t ‑> 'a) ‑> Base.Sexp.t ‑> 'a tval sexp_of_t : ('a ‑> Base.Sexp.t) ‑> 'a t ‑> Base.Sexp.t