What is the point of [@@deriving sexp]?

If you’re asking specifically why Janestreet’s Base/Core libraries use sexp everywhere, it’s because they basically use it as the default data serialization format. See the Data Serialization with S-Expressions chapter in Real World OCaml.

Edit: And if you want to work with Base/Core, you will probably end up sprinkling @@deriving sexp over many of your types as well. Many of their functors require it, and many other things (Map, Set, etc) will work only with the sexp converters, and the deriving sexp is the easiest way to get the functionality.

6 Likes