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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With