Question

So basically I am trying to use Opam to install deriving lib on my Mac.

opam install deriving

I use ocamlfind query and it seems the installation is successful.

#ocamlfind query deriving                                                                                                 
/Users/shuai/.opam/system/lib/deriving 

After install, I try to use ocamlbuild to compile a simple code like this:

type stackop = PUSH | POP deriving (Show, Enum)

let s = PUSH in
  let s' = Show.show<stackop> s in 
    print_string s'

Here is the _tags file:

<*> : package(unix), package(deriving)

and here is the command:

ocamlbuild -use-ocamlfind exp.native

However, I always get this error:

+ ocamlfind ocamldep -package unix -package deriving -modules exp.ml > exp.ml.depends
File "exp.ml", line 1, characters 27-28:
Error: Syntax error
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.

This is quite weird, I am sure the syntax is correct..

Could anyone give me some help?

Was it helpful?

Solution

It seems you forgot to provide deriving.syntax package.

Use the following _tags file:

true: syntax(camlp4o)
true: package(deriving,deriving.syntax)
true: thread,debug,annot
true: bin_annot
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top