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
Allow contractibility annotation in abstract types interface #5863
Comments
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Still worth considering. |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
I am trying to write a library that would benefit from this feature! Is there anything serious that would be blocking a merge of this feature if implemented? |
A first step would be to agree on the syntax. My proposal
It may be a matter of agreeing on a weird new symbol to add to variance-like markers Then you have to implement it. I expect that this will be difficult, but easier than agreeing on the syntax :-) |
From what I understand, adding the annotation to the type declaration in the module is the only place it's appropriate, so it probably doesn't belong with the variance annotations. Maybe something like |
I'm not sure I follow. My idea is to add this on type declarations (and optionally on type definitions but there it can be inferred), in particular on type declarations in the argument of a functor, and to be able to annotate each parameter. For example the following should work, assuming I use module F(X: sig type (#'a, 'b) t end) = struct type u = (u, unit) X.t end
module M = struct type ('a, 'b) = 'b end
module N = F(M) This seems similar to variance to me: module F(X: sig type (+'a, -'b) t end) = struct type +'a u = ('a * 'a, 'a -> unit) X.t end
module M = struct type ('a, 'b) t = 'b -> 'a end
module N = F(M) |
Original bug ID: 5863
Reporter: @gasche
Status: acknowledged (set by @damiendoligez on 2013-06-28T16:12:38Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.00.0
Target version: later
Category: typing
Related to: #5343
Bug description
The fix to #5343 has the compiler safely assume that abstract types are possibly non-contractive. This has the downside of making the following example fail:
Since 4.00.0 this doesn't compile anymore, as "fix" is rejected because M.t is potentially non-contractive.
Could we have a way to specify in a signature that a type is contractive?
(Another option would be to have a type comparison check that is robust in present of type cycles, as in http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.225.6241 , but that is probably not a realistic medium-term change.)
The text was updated successfully, but these errors were encountered: