How safe is using a Marshal string as Irmin content type?


I wondered how safe it is to use Marshal strings of arbitrary ocaml objects to create a generic content type for Irmin. I came up with the following code for a content type for all sexp serializable types:

module type SexpType = sig
  type t
  val t_of_sexp : Sexplib.Sexp.t -> t
  val sexp_of_t : t -> Sexplib.Sexp.t

module SexpContent(
  T : SexpType
) : Irmin.Contents.S with type t = T.t =
  type t = T.t
  let to_raw (x:t) = Marshal.to_string x []
  let of_raw x : t = Marshal.from_string x 0
  let t = Irmin.Type.(like string) of_raw to_raw
  let merge = Irmin.Merge.idempotent (Irmin.Type.option t)
  let of_string s = 
    Ok (T.t_of_sexp @@ Sexplib.Sexp.of_string s)
  let pp ppf x = ppf "%s" (to_string x)

How safe is this code? Since the pp and of_string use the sexp representation, I assume the Marshal string is only used by the running Irmin instance and not by anything that could have a different ocaml version, so it should be safe. Is this assumption correct?

Thank you in advance!