Why does annotating a type with sexp return cause Unbound value int_of_sexp?
camlp4, ocaml
Solution
In more recent versions of sexplib, you need to first `open Sexplib.Std`, which includes the standard type serialization routines in the namespace of the generated code.
So:
open Sexplib
open Sexplib.Std (* newly essential import *)
type t = { foo : int; bar : string; } with sexp
let v = { foo = 3; bar = "baz"; } in
sexp_of_t v
works.
Problem
Using the sexplib syntax extension to automatically generate serialization code for a type, as shown in many simple examples online: ``` open Sexplib type t = { foo : int; bar : string; } with sexp let v = { foo = 3; bar = "baz"; } in sexp_of_t v ``` Fails to compile, with `Error: Unbound value int_of_sexp`.