-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Extraneous ambiguity warning: (MyType{T},T) vs (T,MyType{T}) #1631
Comments
How about Consider the closely related type type NyType{T}
x::T
end which exhibits the analogous ambiguity warning. What does (Not entirely sure how to make the analogous reasoning for |
No, the field x could be uninitialized, so you can have an instance of NyType{None}. Granted, if all constructors of a type throw errors then yes you can't have instances. However the rules of the type system do not depend on the behaviors of constructors. |
So is |
No, undef is not a valid value, but a value with an undefined field is a valid value. |
Ok, so then parametric types are not universally quantified: it is not true that there exists a value |
Perhaps values with undefined fields simply have to be special-cased, so that |
I don't believe so, because a type does not have to be defined by the possibility of constructing it from other values. It can't matter if, for example, none of a type's constructors terminate. |
The specific issue I'm trying to grasp concerns specifically the relationship between parametric types and existentially quantified types; the latter, IIUC, are defined by construction as the image of a type when composed with a function type. I don't see the relevance of computability of a type constructor to this statement. |
The point is that the type system can say a certain type is "inhabited" even if it is not actually possible to construct an instance. I don't think the function type What is so bad about:
? |
All I'm trying to do is to figure out how to express the behavior of Julia's parametric types in terms of "type theory types". Naively I thought NyType{T} :== ∀ x ∈ T : x ⟶ NyType{T}(x) but to cover the case you just described it would at the very least have to be NyType{T} ::= ∀ x ∈ T : x ⟶ NyType{T}(x) | NyType{T}(#undef) If the former were correct then I think I've reached the limit of what I can explain in writing. |
The issue with that formulation seems to be the use of the |
Yes, I really don't think this theory can be based on construction from Tuples (product types) are a different case, because they are, by |
It sounds like the argument for
where It's interesting because the conventional view in type theory is to view an abstract type as either an existentially quantified or a universally quantified type, together with its interface of all allowed operations on them (Mitchell and Plotkin, 1988). In contrast, If tuple types are product types, then they are by definition record types with the trivial labels 1,2,..., which are quantifiable (which I believe is the formal way of saying "made of their elements"), and so it should be true that any tuple type containing a |
This can't be the full explanation though. My hypothetical argument above doesn't explain why
whose only reasonable interpretation is a value of type |
@jiahao as I read @JeffBezanson |
Without assuming the Axiom of Choice, it is quite possible that a tuple type where none of the components is |
@jiahao The issue is that "tagged struct" kinds of types are not defined by |
To clarify, it's not just covariance, but that there is no indirection |
Oh, that's why this is recent. The test is new. It's been failing intermittently on AppVeyor and OSX Travis. |
The code
produces the ambiguity warning
This seems like
S
has been instantiated toMyType{T}
in the intersection, andT
has been instantiated toMyType{S}
.But that would mean that
T == MyType{MyType{T}}
. No type could fulfill this, right?(8 out of the 19 ambiguity warnings here seem to be of this kind.)
The similar case
does not produce an ambiguity warning, though it would have been ambiguous if there were a type
T
such thatT == MyType{T}
.The text was updated successfully, but these errors were encountered: