OCaml attributes

你离开我真会死。 提交于 2019-12-04 12:10:44

The deprecated annotation is only available for values (not on types), and mostly in signatures. In your case, here how it should be done:

module M : sig
  val x : int [@@deprecated "don't use this"]
  type t =
    | X [@deprecated "don't use this"]
    | Y [@deprecated "don't use this"]
end = struct
  let x = 1
  type t = X | Y
end
open M

let _ =
  let y = Y in
  match y with
  | X ->
    print_string (string_of_int x)
  | Y -> assert false

Seems to work from 4.02.3, for this version, #require "ppx_jane";; before your code. With 4.03.0, it works natively.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!