-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dunify #598
base: master
Are you sure you want to change the base?
Dunify #598
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you managed to go forward quite a bit, impressive!
First off, You have lot's of code changes that are due to two things: warnings fixes due to dune's settings, and OMPification of the ppxs. I suggest you pull those out and submit them in separate PRs, so that we can merge them (they are much simpler in nature) and clean up the current PR.
Now, about the core of the PR: Your solution is to segregate shared, client, server and eliom files each in their own folder/library, and enforce some dependency order between them. The goal of eliom is precisely not to organize libraries like that, but to organize them by topic, regardless of where the modules are located. If we want to truly be able to build eliom libraries correctly, we need to have libraries where all kind of files live, and have proper handling of dependencies. Of course, this doesn't prevent to merge an initial dunification which we can refine later (when dune has proper support, for instance).
More concretely:
- I do not see calls to the
type
ppx, how does that work ? - you renamed
*.eliom[i]
files ineliom/*.ml[i]
. This doesn't seem necessary. - You currently suppose that we have two building scheme, one for client and one for server. This is not the case with my new implementation. It would be nicer to only suppose you have one build scheme that output 2 things (and which happens to call 2 ppxs currently). This would provide a better way forward.
src/lib/client/eliom_bus.ml
Outdated
@@ -46,6 +46,7 @@ let consume (t,u) s = | |||
| Lwt.Sleep -> Lwt.wakeup_exn u e; | |||
| _ -> ()); | |||
[%lwt raise ( e)] | |||
[@ocaml.warning "-22"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure you can just turn those into Lwt.raise
, and get rid of the extension node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made to satisfy Dune's default settings, which are very strict on compiler warnings. As per your suggestion, I've pulled it out of the PR.
src/ppx/.merlin
Outdated
S /home/chrismamo1/.opam/default/lib/result | ||
S . | ||
FLG -ppx '/home/chrismamo1/Documents/work/BeSport/pgocaml-ppx-porting/eliom/_build/default/.ppx/1f6b9d3f3f2366a895b212642c81f26e/ppx.exe --as-ppx --cookie '\''library-name="ppx"'\''' | ||
FLG -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just drop the merlin file, since they are dune-generated.
@@ -315,7 +312,6 @@ module type Pass = sig | |||
val client_sig: signature_item -> signature_item list | |||
val server_sig: signature_item -> signature_item list | |||
|
|||
(** How to handle "[%client ...]" and "[%shared ...]" expr. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing comments?!
... x ... | ||
] | ||
] | ||
*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
src/ppx/ppx_eliom_utils.ml
Outdated
| "", false -> () | ||
| _, true -> Location.raise_errorf ~loc:Location.(in_file !input_name) | ||
"Wrong arguments:@ %s" (String.concat " " (Array.to_list Sys.argv)) | ||
| x, _ -> Mli.type_file := Some x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are already using Arg
, you should use the ~args
argument of Migrate_parsetree_driver.register
.
src/lib/eliom/eliom_service_base.ml
Outdated
k | ||
| _ -> | ||
failwith "non_attached_info" | ||
. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware, this restrict to fairly recent OCaml versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made to satisfy Dune's default settings, which are very strict on compiler warnings. As per your suggestion, I've pulled it out of the PR.
move *.client.ml* and *.server.ml* lib files into their respective directories move *.shared.ml* files into shared directory and add symlinks refactor the ppx to support standalone and factor .eliom files back out actually compile things fix building multiple tools delete ppx use external ppx tools fix a dependency issue and update some possibly-obsolete package names create eliomopt alias
48d2d23
to
2601a53
Compare
@Drup thank you very much for the input. I've pulled all the compiler warning fixes out, and will submit a new PR once this one has been dealt with. For simplicity reasons, I think it would be best to pull the PPX and Camlp4 rewriters into separate opam packages, with As for your specific concerns:
|
Agreed, but keep everything in this repository for now. Dune works particularly well for this, and opam support it just fine. And please don't push things to the opam repository before it's discussed and we have reached a stable solution. In particular it's completely unacceptable to have some eliom packages pointing to github repositories that are not under the ocsigen umbrella.
If the typing files are not available, the typing is basically ignored. This is wrong as it means injections and fragments are unchecked and makes eliom's typing completely useless. Arguably, it should lead to an error, but unfortunately it currently doesn't. The fact that eliom code compiles is not sufficient to assert that eliom works. You also need wrong code to fail. :)
Yes. |
@chrismamo1 are you still working on this? |
Not actively, no. |
I see. I was wondering if you were interested in upstreaming eliom support in dune itself. It would be nice if people didn't have to manually write eliom/eliomi rules :) |
I think dune support would be a tremendous help. Judging from my own experience, using manual rules is infeasible. Just getting it to compile is straight forward, but getting the dependencies right for server-client type-checking is tricky. That also means adding dune support may be less straight forward than one would think. I hope that doesn't sound too scary. Someone correct my if I'm wrong, but the rough approach to compiling an Eliom applications is:
We should take advantage of the dependencies in the first step to parallelize across the succeeding steps. Note that a client side compilation unit will depend on the corresponding server side inferred type in addition to the regular dependencies, and the inferred type may have it's own dependencies on the server side. One thing we need to consider is that client-side must have a different build directory from the server side since the module names of the compilation units overlap. |
@paurkedal Indeed that sounds involved. It seems like you know quite a bit of what's required. If you're interested, I can help you understand the require parts of dune needed to implement this feature.
That would be a good first step to look into in dune. |
@rgrinberg I would like to take you up on that offer in a couple of months when I have more time to spare, but just to get the thoughts going: We could try to generalize dune to support eliom-style flows or we could make a specialised rule. I think the latter is most realistic given how I understand the dune design as an end-user. Keeping all sources in a single directory for server and client is encouraged, using (eliom_application
(name ...) (public_name ...)
(eliom_modules ...) (shared_modules ...) (client_modules ...) (server_modules ...)
(shared_libraries ...) (client_libraries ...) (server_libraries ...)
(shared_flags ...) (client_flags ...) (server_flags ...)
(shared_preprocess ...) (client_preprocess ...) (server_proprocess ...)
...) but we could also make server library and client executable nested with shared properties factored up. Next, it would also be good to support building Eliom libraries, which would consist of two libraries, a server and client, where the latter is bytecode only. Otherwise the same logic regarding inferred mli files, PPXes, and dependencies applies. |
What about eliom libraries? Isn't it possible to define a library with client & server side components? |
Yes, I think an |
I see. I wonder if it's simpler to just an |
But note that there is a tight relation between the client and server side, both since declarations of modules and library dependencies will overlap (i.e. the |
I imagine support for an |
Eliom now compiles in ~17s on my machine, whereas the
master
branch takes up to 100s.This also factors the eliom PPX into a separate package, although I suspect it would be possible to avoid doing that.
It also completely removes the
syntax
package, which I believe is necessary asdune
actively discourages camlp4 use. This will breakocsigen-start
, since that still relies on Macaque's camlp4 extension, so it cannot use PPX.