目前我正在尝试使用Batterieswithppx_deriving.show或类似的东西。
我想知道如何有效地一起使用它们。
要创建转储函数,我觉得 ppx_deriving.show 很有用。但是我在使用它们时遇到了一些麻烦,如下所示。
open Batteries
type t = { a: (int,int) Map.t }
[@@deriving show]
nowMap.pp没有定义,所以无法编译。
我的临时修复是我创建module Map了包含Batteries.Map和定义函数pp。
open Batteries
module Map = struct
include Map
let pp f g fmt t = ... (* create dump function by man hand *)
end
type t = { a: (int,int) Map.t }
[@@deriving show]
它有效,但对我来说适应所有数据结构很痛苦......
Corewithppx_deriving.sexp是另一种选择,但我更喜欢Batterieswith ppx_deriving.show。有谁知道如何解决这个问题?