3 ms·
No, that's what the ppx rewriter is for (the metaprogramming I mentioned). You write type foo = ... with sexp and those functions will be generated automaticall
by rbehrends 11y ago
No, 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)