-
Notifications
You must be signed in to change notification settings - Fork 7
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
should the proposal include type exports? #4
Comments
Interesting point. Not sure it would be great to split this up further, since it'd be oddly asymmetric to have imports but no exports. Either way, I think that type generativity should not be coupled to exports, since that makes for a rather complex semantics -- you'd get into many of the technical complications of the "sealing" construct for ML modules. Instead, it would be both simpler and probably more usable to make it a future feature of type definitions themselves. Similarly, I think that the natural semantics for type exports is to be fully transparent. If we wanted to introduce some form of abstract export we can always add that later. But I suspect this is more or less the same problem as the first one, with the same answer, too. |
Thanks, good points. If I could dig in a bit: Agreed that generativity belongs on the type definition. So then, considering #3, does that mean that Abstract exports is more of what I'd like to understand. It seems like we'd need an export statement of the form "export Concretely, I'd like to understand how the answers to these questions come together to allow a module |
Good question. A common way to support abstract data types in user-facing languages is having some form of explicit injection/projection operators that can be hidden independently from the type itself. For example, in Haskell you have the
This defines the type I'm not entirely sure yet what the best way would be to port such a mechanism to Wasm, but it should be doable somehow. FWIW, the exception proposal already introduces a notion of constructor that enables the same kind of abstraction, though it is designed for a different use case and isn't a no-op. (But the exception example also shows that abstraction/encapsulation does not necessarily require introducing generative types if you already have generative values. But they seem necessary if you want to make abstraction a no-op.) |
Ah hah, so, iiuc, the So then, iiuc, with the current proposal in this repo, all types are non-generative and non-abstract, with generativity/abstract types addable in the future by adding new kinds of type definitions? |
Yes, yes, and yes. :) |
Ok, cool, thanks for the discussion! |
Thinking a bit more about type imports after #3, type exports actually raise some pretty important questions that, iiuc, we could otherwise punt on if all we really need in the short term (at least for getting statically-typed calls to host APIs) is type imports.
In particular, with type exports there are some interesting questions about:
(sub ...)
bounds) or is it possible for me to export a type that is fully abstract (such that no other module can give it a type more specific thanany
)Both relate to how type exports can be used to implement abstract data types, which I think is important, but technically not a problem we have to solve right now in this proposal, at least as currently motivated.
The text was updated successfully, but these errors were encountered: