-
Notifications
You must be signed in to change notification settings - Fork 31
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
Rewrite Idl to unifiy almost all GenClient and GenServer under a functor #117
Conversation
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
The latest version should work, at least passes all the tests on my machine. If you review the code you will see that the current state requires some ugly returns and There is definitely more work needed, but before moving on I'd like to get some feedback and ideas on how to restructure it further to simplify the issues mentioned above (they are clear if you look at the changes needed for the examples to work). |
Signed-off-by: Marcello Seri <[email protected]>
|
I'd be interested in that idea using GADTS, it's great if that makes it easier to use. |
src/async/rpc_async.ml
Outdated
module M = struct | ||
include AsyncIdl.ImplM | ||
(* TODO: can we avoid Obj.magic here? *) | ||
let deferred x : 'a Async.Deferred.t = Obj.magic (AsyncM.unbox 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.
Yeah, I think this was the line I didn't cross when trying to do this...! Not that I'm saying it's a showstopper because unifying these things certainly reduces a large amount of copy-pasted code.
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 think this can be avoided, I have only to figure out what is the best way
tests/rpc/client_lwt_new.ml
Outdated
@@ -125,7 +125,7 @@ let main () = | |||
Server.rpc4 ImplM.rpc4; | |||
|
|||
let funcs = Server.implementation in | |||
let rpc = rpc (Rpc_lwt.server funcs) in | |||
let rpc r = rpc (Rpc_lwt.server funcs |> Obj.magic) r |> Obj.magic in |
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.
Although leaking Obj.magic calls into the code that end-users of the library write is a lot more worrying.
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 thin this should be avoidable as well. One of these calls is actually Rpc_lwt.M.lwt
but I realised it only later
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.
Anyways I agree with you that, if this requires leaking Obj.magic
, then is the wrong approach.
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
The latest version does not require any From the test and examples updates it seems clear that a new combinator is needed in the Naming has improved a lot in my opinion, although there is quite a lot of room for improvement. I guess the next steps are:
|
…yle if we want to be pedantic Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
In fact, it did not ocamlformat the following - ppx_deriving_rpc (because it uses cppo) - examples/example3_idl (reported bug) - tests/libs/json (reported bug) Signed-off-by: Marcello Seri <[email protected]>
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.
Thanks so much, looks great! Just some comments about unused things, I'll do a proper review soon, after the Gen...Exn
behaviour is finalized.
src/lib/idl.ml
Outdated
|
||
[@@@warning "-32-34"] | ||
|
||
module type RPCTRANSFORMER = functor (M : MONAD) -> sig |
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 seems to be unused
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.
Yes, It is kind of legacy you are right. I may resuscitate it to simplify further the interface of Rpc_lwt
and Rpc_async
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.
That would be useful, because we use the async one in xapi-storage-script
.
|
||
val return : 'a -> 'a box | ||
|
||
val get : 'a box -> 'a M.t |
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.
unbox
and get
seem to be the same - but if we want more synonyms for readability that's fine by me
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.
Well spotted, with the last interface put
and get
are the same as box
and unbox
. I like the former more, what do you think?
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 agree, they just sound better :)
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
Signed-off-by: Marcello Seri <[email protected]>
@gaborigloi I have updated the interface with the |
Merged to include the recent fixes and resolve the merge conflicts (doing a rebase was too painful and error prone) |
@jonludlam Should we just merge & test it on a branch, and then refine it later (by removing e.g. the legacy exn stuff that we don't need)? |
We've agreed to merge this. |
After reading https://discuss.ocaml.org/t/reducing-mirageos-image-size-using-ocamlclean/ I double checked the dependencies, and updated the jbuild file of the ppx rewriter. It does not affect the size of the executables though, so it should not have anything to do with the discussion there |
I have also moved to ppx_tools_versioned that should allow us to drop the need of ppxfind and cppo (needs testing with different compilers though, so we'll need to wait for travis to know better) |
Signed-off-by: Marcello Seri <[email protected]>
I took the last thing back. Unless ppx_deriving is converted to omp, it is not possible to drop cppo and the use of ppxfind |
Ping, any progress on this? |
We wanted to just merge it and create a feature branch with @jonludlam to test it. |
Do not merge yet. This is a work in progress and I am posting it here for discussion.
I have now found a structure that compiles and allows to unify GenClient and GenServer for the Result.result, lwt and async interfaces. This does not yet work with the
Exn
version of the Client and Server.Also some more cleanup needs to be done, e.g. pass the RPCMONAD in a Make functor that generates all the modules and unify the interfaces and signatures.