-
Notifications
You must be signed in to change notification settings - Fork 47
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
Types in a module default to private #61
Conversation
For consistency later with export_type.
Explicit import and export now via import_type and export_type respectively. The latter allows exporting multiple comma-separated types.
Closes #48 |
If you have an exported function returning a value of an unexported type you will get an error like below in the module using that exported function:
I'm not sure that is what we want. I think what we want is that all type names are exported, but that type representations are not. i.e. in the OCaml example from ticket #34, the type name It is some time since I thought about this last and there is probably some flaw in my reasoning above, but my main goal is to be able to define completely abstract data types. |
Correct me if I'm wrong but that error should only occur if we're actually trying to use the implementation of an un-exported type, e.g. in pattern match on the value returned by the exported function. Isn't this relatively consistent with what you're after? I haven't yet tried a test out to confirm that this is correct on my part, mind :) Having said that, your point about all names being exposed but implementations not so without explicit export does make a lot of sense. I expect you want to be able to include the type names in other (external to the defining module) types but not expose the implementation. Is that more or less accurate? I think there might be a role here still for |
To answer your first question, consider this:
This will fail with Regarding your second question. Yes, you got it right. And lastly, regarding |
Interesting - the error you're describing is a bug in the typer itself. I think it's typing functions in the environment of the module calling into the other with the private type rather than in the module that owns the function. |
Thanks to @danabr for surfacing this bug. Functions called in another module were getting typed without their module's environment (types, etc).
@danabr updated with a fix for that bug. |
Importing and exporting via
import_type
andexport_type
.@danabr I'd be curious to hear any thoughts on these changes if you have a moment as they're based on an example you brought up.