Closed fare closed 6 years ago
NB: Please review carefully, since I have no idea what I'm doing.
I admit I am incompetent as to the distinction between deriver and rewriter, and cannot comment. The code looks like it mostly works for me. However the existing test file fails, seemingly because of conflict between the [@@deriving lens]
from a module and from its interface.
As for testing... so far I have only tested with 4.06.1. I'm not too sure how to test with other versions.
François-René Rideau notifications@github.com writes:
As for testing... so far I have only tested with 4.06.1. I'm not too sure how to test with other versions.
Have you considered using opam:
$ opam switch create 4.05.0
etc.
François-René Rideau notifications@github.com writes:
I admit I am incompetent as to the distinction between deriver and rewriter, and cannot comment. The code looks like it mostly works for me. However the existing test file fails, seemingly because of conflict between the
[@@deriving lens]
from a module and from its interface.
The difference is in the META generated. A deriver needs some extra stuff to make it work with ppx_deriving's dynlink.
First of all I want to apologise for the delay, I have very few spare time for side projects.
My problem in this context is that I don't use jbuilder so I don't know how it works.
The patch essentially adds the configuration files for jbuilder and proposes a different build system in the opam file.
Questions:
ocaml-version >= "4.03.0"
but did you tried with all of those versions of the compiler?Otherwise we have to tackle this problem in a different way, maybe asking help to the jbuilder team.
I didn't test with 4.03 or anything but 4.06.1: I just adapted the statement from some existing configuration file for jbuilder.
I'll try at least with 4.05 to see how it goes...
The lenses work for me in a private project. The given test file, on the other hand, doesn't work (see above).
@fare I want to solve this issue of course but I need some help from you.
jbuild
file to compile the hello_world with the libraryOnce I can compile a simple program with your patch and jbuilder I'll try to compile the same source and lib with ocamlbuild, let's see what happen.
The point here is to avoid to compromise the build chain of all the existing projects using lens with a "jbuilder only" release.
I added a hello example using lenses.
I failed to make [@@deriving lens]
work with { submodule = true }
. submodule = true
also fails in the previously provided ppx_test
. Is it because I use OCaml 4.06.1 versus earlier? Because I use Migrate_parsetree
? Because of jbuilder
itself? I don't know. I'd bet something incompatible changed about the AST for modules.
I read a lot of threads here and there and I have to admit that... it's really a mess (ocaml-ppx/ppx_deriving#153).
The current state is:
There are two issue here: one "political" (against duna, Jane Street, etc.) and one technical: I don't know how duna works and why it doesn't find the installed library.
I want to be pragmatic and ideally provide an OPAM package for lens which:
Here the only person that seems to understand the issue in deep is @rgrinberg: I read your comments here: ocaml-ppx/ppx_deriving#153
Do you know what is the present state of duna/ppx_deriving discussion? Do you think I (we) can fix this tiny library and make everybody happy?
There is at least one solution, but it's really ugly: to keep lens as it is and publish another OPAM package, lens-duna, compiling with this build system. I'd like to avoid such an abomination but as I said I'm a pragmatic person and I don't want to fight against Jane Street or any other in the OCaml community, for a library of just two files, defending a "principle".
@rgrinberg if you can help, please... If you can't or you don't care but you know someone who can give help, I'll appreciate very much.
Wait. Was dune
renamed to duna
or was that a typo? In any case, I had no problem building with jbuilder
as itself installed by opam install jbuilder
in a 4.06.1
installation.
Paolo Donadeo notifications@github.com writes:
Do you know what is the present state of duna/ppx_deriving discussion? Do you think I (we) can fix this tiny library and make everybody happy?
All of the problems have been fixed and ppx_deriving is compatible with drivers, omp, and type_conv. Though it might be required to drop 4.02 support (and possibly 4.03 as well).
There is at least one solution, but it's really ugly: to keep lens as it is and publish another OPAM package, lens-duna, compiling with this build system. I'd like to avoid such an abomination but as I said I'm a pragmatic person and I don't want to fight against Jane Street or any other in the OCaml community, for a library of just two files, defending a "principle".
@rgrinberg if you can help, please... If you can't or you don't care but you know someone who can give help, I'll appreciate very much.
I'll have a look at the port today. The time that I have to spend on this port is limited, because I don't really have time for this.
What I'd like to see is testing of this port with different versions of OCaml.
@fare sorry, "dune" is a typo, maybe too much Herbert reading... Yes i confirm I can compile the lib with jbuilder but I don't know how to install it and then to compile the hello example linking using that installed library.
@rgrinberg thanks, good news. I'll investigate more on the jbuilder side. I believe it should be possible for an ocamlbuild-generated library (which is a f***ing regular object from the OCaml compiler) to be linked with the example, using jbuilder.
The problem is: why jbuilder don't even find the library?
@rgrinberg thanks, good news. I'll investigate more on the jbuilder side. I believe it should be possible for an ocamlbuild-generated library (which is a f***ing regular object from the OCaml compiler) to be linked with the example, using jbuilder.
The issue is that dune expects a different packaging standard for ppx's. Jbuilder expects a ppx to register with a driver so that it can link all them all into a single preprocessor. So all you'd really need is to write a correct META file and use omp.
@rgrinberg thanks, that was a good hint!
I'm on the right track and I have an almost-working local branch.
@fare @rgrinberg I can confirm I can build lens and install it with OCaml >= 4.041. The installed library can be linked with the example provided by François-René (using jbuilder) and with an old project of mine still using ocamlbuild.
I'll release as soon as possible.
On the other hand, the jbuilder recipe explicitly uses versioned parse trees (as required by jbuilder), with 4_06 being the version I used (because it's the version I tested), so it won't build with older versions. If you believe I ought to use an older version than 4.06, that's trivial to change and test.
@fare my proposal is to test the new package in your environment.
opam uninstall lens
git clone https://github.com/pdonadeo/ocaml-lens.git; cd ocaml-lens
git checkout -b jbuilder origin/jbuilder
opam pin add lens .
In this environment I can compile your hello_lens with jbuilder runtest
using this jbuild file:
(jbuild_version 1)
(executable
((name hello_lens)
(modules (hello_lens))
(libraries (lens))
(preprocess (pps (lens.ppx_deriving)))))
(alias
((name runtest)
(deps (hello_lens.exe))
(action (run ${<}))))
I hope this also works for you, let me know.
@fare meanwhile I can confirm that the new version of lens (compiled and installed with jbuilder) works with an old project of mine, still in production. It also works (at least here) with your example, can you confirm it also works with a more realistic project of yours?
@rgrinberg since nobody seems interested anymore... Do you think you can make a quick check if the jbuilder
branch works in a typical environment using dune?
If you can't I'll merge the branch and publish a new version.
Yes, it works perfectly for me with jbuild on my open-source-but-not-released-yet project.
NB: the jbuild version explicitly requires the versioned ppx for OCaml 4.06, and so won't work with older versions of OCaml.
Ok, very nice! This week end (sorry, its only monday...) I'll release.
Meanwhile you can opam pin
the jbuilder
branch.
Build it will jbuilder.
Use ppx_tools_versioned so it works with jbuilder preprocessing.