-
Notifications
You must be signed in to change notification settings - Fork 33
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
Forward type definitions #2
base: master
Are you sure you want to change the base?
Conversation
I think this PR tries to address a genuine problem. The motivation and technical details are pretty clear in the description. All in all a pretty good first RFC for the repo. I think the main thing missing from this RFC is a description of drawbacks and alternatives. I think it is important that RFC authors try to include these as well, since they are an important part of any decision. Some apparent drawbacks of this proposal might be:
Some possible alternatives include:
The last of these alternatives is particularly relevant as I have been working with @OCamlPro-Couderc on a proposal to support just such recursion. I'll try to write that proposal up as its own RFC in the next few days. |
In terms of processes, I thought the goal was to discuss and agree or reject a document that specifies, in more or less details, a solution to be implemented. So the RFC itself would only describe the target solution, and the discussion around the merits, drawbacks and alternative would be part of the discussion in the PR (and I should have listed drawbacks in the PR description indeed). Do you have a different understanding?
Is this something public, and if so, could you share a reference? I can imagine this is based on a generative functor producing a fresh abstract type, plus its At least as a temporary workaround before we get full recursion in the language, this solution might indeed works well, and support higher-level abstractions than my proposal. One problem I can foresee is the lack of "global opening of GADT", which would allow: type (_, _) eq = Eq: ('a,'a) eq
module F(X : sig type t type s val x : t val y: s val eq: (t, s) eq end) = struct
let Eq = X.eq
let _ = (X.x = X.y)
end One needs to open
Does this bite you in practice when using your library? Do you think one could imagine extending support for GADTs opening to support code as above, or are there deep problems here?
Looking forward to reading your forthcoming RFC. One critical point, in some contexts at least, is to preserve separate compilation and incrementality of the build. |
I had a slightly different understanding, where the document describes both the solution to be implemented and a summary of the main considerations that lead to that choice. So we would discuss alternatives, advantages and drawbacks in the PR and then include outlines of those in the document itself. This is based on how the Rust RFC process seems to work -- their RFC template: https://github.com/rust-lang/rfcs/blob/master/0000-template.md explicitly includes sections for these bits and it does seem to be helpful. I'm open to doing things either way, but we should try to decide which approach we want to take and then update the Readme to reflect the decision.
I'm afraid it isn't in our open source libraries.
I haven't looked in close detail, but that is my understanding of how it works.
My understanding is that this is indeed a bit annoying but not terrible. You kind of start every function with
I think you definitely could add such support. The tricky part is that you need to check some things about any types which escape the scope of a GADT equation, so we'd need to do that for everything defined in the module after that point. I think that is just work to do rather than something fundamentally difficult, but I haven't thought too deeply about it. @garrigue, @trefis, do you have some idea of what "global opening of GADTs" would entail? |
See #3 |
Sorry for the very slow answer. Note also that the nominal types proposal (#4) allows witnesses to add equations to parameterized abstract types. This said, a GADT based approach is not only heavy-weight, it may also be very dangerous if you start using The more natural approach is to use functors (this is exactly what they are about), combined with recursive modules. It would be interesting to see where it becomes intractable to use them. |
A proposal to add "forward type definitions", allowing in particular mutually recursive type definitions to be split into multiple compilation units.