如何使用[@ ocaml.warning“ -30”]隐藏警告30

时间:2018-09-13 07:55:33

标签: functional-programming ocaml

我有两个相互依赖的记录,并且两个记录都有相同名称的字段。如何使用ocaml.warning属性隐藏此警告?我想避免使用类似[@@@ocaml.warning "-30"] my types here [@@@ocaml.warning "+30"]之类的东西。

# type a = {a : int;} and b = { a:int;};;
Characters 30-36:
Warning 30: the label a is defined in both types a and b.
type a = { a : int; }
and b = { a : int; }

1 个答案:

答案 0 :(得分:1)

这可能不会比您想要避免的包围结构好,但它对我有用:

# module M = struct
    type a = {a: int} and b = {a: int}
  end [@warning "-30"];;
module M : sig type a = { a : int; } and b = { a : int; } end
# type a = M.a and b = M.b;;
type a = M.a
and b = M.b