首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置ocamlinit以使ppx正常工作?

如何设置ocamlinit以使ppx正常工作?
EN

Stack Overflow用户
提问于 2016-12-28 07:37:40
回答 2查看 600关注 0票数 2

这是我的ocamlinit:

代码语言:javascript
复制
(* Added by OPAM. *)
let () =
  try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
  with Not_found -> ()
;;

(* ## added by OPAM user-setup for ocamltop / base ## 3ec62baf6f9c219ae06d9814069da862 ## you can edit, but keep this line *)

#use "topfind";;
(* ## end of OPAM user-setup addition for ocamltop / base ## keep this line *)

#thread;;

(* #ppx "ppx-jane -as-ppx";; *)
#require "ppx_jane";;
#require "core.top";;
#require "async";;
#require "core_extended";;


open Core.Std;;

就是这样,我在utop中得到了这个

代码语言:javascript
复制
utop # type test = char list [@@deriving show];;
Error: Cannot locate deriver show 

如果使用以#ppx开头的行,而不是以#require "ppx_jane"开头的行,则会出现以下错误

代码语言:javascript
复制
utop # type test = char list [@@deriving show];;
Error: ppx_type_conv: 'show' is not a supported type type-conv generator

我应该如何设置ocamlinit来使用[@@deriving show]

EN

回答 2

Stack Overflow用户

发布于 2016-12-28 13:43:24

我设法使用#require "ppx_deriving.show";; (不管有没有#require "ppx_jane";;)让它工作。

票数 1
EN

Stack Overflow用户

发布于 2016-12-28 23:21:50

除了皮埃尔的建议之外,我还发现我需要与ppx_jane沟通。

此外,我使用#require "ppx_deriving.std"而不只是ppx_deriving.show来获取ord和其他东西。

这是我的完整的ocamlinit

代码语言:javascript
复制
(* Added by OPAM. *)
let () =
  try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
  with Not_found -> ()
;;

(* ## added by OPAM user-setup for ocamltop / base ## 3ec62baf6f9c219ae06d9814069da862 ## you can edit, but keep this line *)
#use "topfind";;
(* ## end of OPAM user-setup addition for ocamltop / base ## keep this line *)

#thread;;

#require "ppx_jane";;
#require "core.top";;
#require "async";;
#require "core_extended";;

#require "ppx_deriving.std";;

open Core.Std;;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41353529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档