Type Error in OCaml Code

Hi everyone,

I have already asked this question on OCaml mailing list, but so far there is no response and hence posting here.

My Coq project depends on a OCaml library [1] --the original library [2]-- which used to compile without any error in the past, but now it’s no more. If you run ‘make all’ in the ocaml-java directory, it throws an error ‘This expression has type Parsetree.pattern
but an expression was expected of type
Migrate_parsetree.Ast_406.Parsetree.pattern’

Could someone please tell me how to get rid of this error? (To me it seems like some code restructuring in ocaml-migrate-parsetree).

Best,
Mukesh

ocaml-java git:(master) ✗ make all

File “ppx/ast_tools.ml”, line 31, characters 36-55:
31 | let mk_let id expr = [%stri let [%p Pat.var (mk_loc id)] = [%e expr]]
^^^^^^^^^^^^^^^^^^^
Error: This expression has type Parsetree.pattern
but an expression was expected of type
Migrate_parsetree.Ast_406.Parsetree.pattern
make[1]: *** [bin/ppx/ast_tools.cmo] Error 2
make: *** [bin/ocaml-java-ppx] Error 2

[1] EncryptionSchulze/code/Workingcode/ocaml-java at master · mukeshtiwari/EncryptionSchulze · GitHub
[2] GitHub - Julow/ocaml-java: [WIP] Java <-> OCaml interface

Hi! This library hasn’t been updated in a long time and doesn’t work with the newer versions of some of its dependencies.

You need ocaml-migrate-parsetree version 1.8.0 or below. (the version just before 2.0.0)

Note that this library has never been released and never really been used and tested in a real project. Expect to have many bugs. (happy to help)

Hi @Juloo, thanks for the reply, again. Are you aware of any library that has similar functionality as yours and also maintained?

I installed 1.8.0 --ocaml-migrate-parsetree 1.8.0 pinned to version 1.8.0-- but now there is a different error:

ocamlfind ocamlc -package ppx_tools.metaquot,ocaml-migrate-parsetree -linkall -linkpkg -I bin/ppx -open Migrate_parsetree -open Ast_406 -c ppx/ast_tools.ml -o bin/ppx/ast_tools.cmo
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/keep_learning/.opam/4.12.1/lib/ocaml, /Users/keep_learning/.opam/4.12.1/lib/ocaml/compiler-libs
File "ppx/ast_tools.ml", line 1:
Error: Unbound record field Parsetree.ptyp_loc_stack
make[1]: *** [bin/ppx/ast_tools.cmo] Error 2
make: *** [bin/ocaml-java-ppx] Error 2

It seems that the library isn’t compatible with ocaml >= 4.08. You need ocaml 4.07.1.

I’ll try to update the library during the week but it seems that you are using an older version. Maybe because you can’t use Dune in your build system ?

No, I don’t think I am using Dune build system. There is no problem for me to use Dune, except it may take quite some time that I don’t have at the moment. Also, at the moment, I am trying to take the path of least resistance but I should reorganise my code and use Dune build system.