2016-12-27 78 views
1

这是我ocamlinit:如何设置ocamlinit以便ppx有效?

(* 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

utop # type test = char list [@@deriving show];; 
Error: Cannot locate deriver show 

如果我用#ppx代替#require "ppx_jane"开头的行,我得到这个错误

utop # type test = char list [@@deriving show];; 
Error: ppx_type_conv: 'show' is not a supported type type-conv generator 

我该如何设置ocamlinit才能使用[@@deriving show]

回答

1

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

+0

我试过了,但我得到了'没有这样的包:deriving.show'。 – ackerleytng

0

除了皮埃尔的建议,我发现我需要ppx_jane

此外,我用#require "ppx_deriving.std"而不是只是ppx_deriving.show得到ord和其他的东西。

这里是我的全ocamlinit

(* 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

唉!它在emacs utop中仍然不起作用。当我做C-C C-B时,Utop似乎将[@@ deriving show]视为不在那里。 – ackerleytng

+0

但是,如果我在每个命令上单独执行C-x C-e,则utop似乎对所有内容都可以。 – ackerleytng