3 ms·
Thank you. s-exps are a pain, because you have to manually specify the function sexp_of_t for any type t that you want to support
by pathsjs 11y ago
Thank you. s-exps are a pain, because you have to manually specify the function sexp_of_t for any type t that you want to support
- rbehrends 11y agoNo, that's what the ppx rewriter is for (the metaprogramming I mentioned). You write type foo = ... with sexp and those functions will be generated automatically for you. Mind you, the whole Jane Street Core machinery is still a bit heavyweight for my taste, but that particular concern shouldn't be an issue. For example, in utop: utop # #require "core";; utop # #require "core.syntax";; utop # open Core.Std;; utop # type foo = int * string with sexp;; type foo = int * string val foo_of_sexp : Sexp.t -> foo = <fun> val sexp_of_foo : foo -> Sexp.t = <fun> utop # sexp_of_foo (1, "foo");; - : Sexp.t = (1 foo)