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.