janestreet / base

Standard library for OCaml
MIT License
860 stars 125 forks source link

Missing sexp_of_opaque #97

Closed amongonz closed 4 years ago

amongonz commented 4 years ago

Base doesn't reexport sexplib0's sexp_of_opaque (nor opaque_of_sexp), despite it even being mentioned in the docs for Type_equal.Id. I'd expect it to be in Base since its the only function that makes sense when you lack a proper implementation for Type_equal.Id.create or Comparator.make.

For now, I'm just using Sexplib0.Sexp_conv.sexp_of_opaque directly.

bcc32 commented 4 years ago

Thanks for catching this. sexp_opaque as a type has been deprecated and superseded by the [@sexp.opaque] attribute, which makes me a bit hesitant to expose the corresponding sexp_of_opaque function.

If you're using ppx_sexp_conv, you can use [%sexp_of: _] as a substitute, or [%sexp_of: _[@sexp.opaque]] if you specifically want the output to be <opaque>. You can also add [@sexp.opaque] to a type definition with [@@deriving sexp] to achieve the same effect.

Otherwise, does (fun _ -> Sexp.Atom "<opaque>") work for you?

amongonz commented 4 years ago

If sexp_of_opaque has been left out on purpose then yes, those will do. While I've got ppx_sexp_conv available, the editing experience around PPX is not particularly pleasant at the moment so I'll take the latter option for now.