Module Sexp_maybe

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.


type 'a t = ('a, Sexplib.Sexp.t * Error.t) Result.t
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 compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val bin_read_t : 'a Bin_prot.Read.reader -> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader -> (int -> 'a t) Bin_prot.Read.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