Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 sexplib 语法扩展为一个类型自动生成序列化代码,网上很多简单的例子都有展示:
open Sexplib type t = { foo : int; bar : string; } with sexp let v = { foo = 3; bar = "baz"; } in sexp_of_t v
编译失败,有Error: Unbound value int_of_sexp.
Error: Unbound value int_of_sexp
在较新版本的 sexplib 中,您需要首先open Sexplib.Std在生成代码的命名空间中包含标准类型序列化例程。
open Sexplib.Std
所以:
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
作品。