Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing abstract syntax tree using ppx_deriving

Could some please tell me why this code is not compiling. I am trying to print the abstract syntax tree using ppx_deriving library.

type prog = command list
[@@deriving show]
and command =
   | Incv | Decv
   | Incp | Decp
   | Input  | Output
   | Loop of command list
   [@@deriving show]

let _ = Format.printf "%s" (show_prog ([Incv, Incv]))

hello:brainfuckinter mukeshtiwari$ ocamlbuild -package ppx_deriving.std  ast.byte
+ /Users/mukeshtiwari/.opam/4.02.1/bin/ocamlc.opt -c -I /Users/mukeshtiwari/.opam/4.02.1/lib/ppx_deriving -o ast.cmo ast.ml
File "ast.ml", line 10, characters 28-37:
Error: Unbound value show_prog
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in 00:00:00.
hello:brainfuckinter mukeshtiwari$ ocaml
    OCaml version 4.02.1
like image 658
keep_learning Avatar asked Jul 24 '15 10:07

keep_learning


1 Answers

Add -use-ocamlfind as first argument of ocamlbuild. It should solve the issue.

(You also have a typo in [Incv, Incv], the , should be a ;.

like image 125
Drup Avatar answered Sep 29 '22 16:09

Drup