Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upThe pi type trilogy #1930
Comments
ticki
referenced this issue
Feb 26, 2017
Closed
RFC: Constant generics (restricted Π types) for Rust, core RFC (v2) #1931
This comment has been minimized.
This comment has been minimized.
|
First rfc up: #1931 |
This was referenced Feb 26, 2017
This comment has been minimized.
This comment has been minimized.
fottey
commented
Feb 26, 2017
|
Thank you very much @ticki for continuing to champion this feature proposal. I appreciate all your hard work. |
This comment has been minimized.
This comment has been minimized.
burdges
commented
Feb 26, 2017
This comment has been minimized.
This comment has been minimized.
|
Discussion from the first RFC that's worth noting here:
I personally agree that we should come up with a much better name than Π types for this. We're not gonna use that name in the Rust book, and while understanding type theory is necessary for implementation, I don't think it's necessary for the average user. |
This comment has been minimized.
This comment has been minimized.
|
We don't talk about Σ types at all when we're discussing Rust's type system and I think that talking about Π types is equally silly. |
This comment has been minimized.
This comment has been minimized.
|
@clarcharr I fully agree. Only the last proposal is true dependent types. |
This comment has been minimized.
This comment has been minimized.
Twey
commented
Feb 27, 2017
|
Well, that's because Rust doesn't have Σ-types either, surely? |
This comment has been minimized.
This comment has been minimized.
|
@ticki As I read through the RFCs, I continue to be amazed at how well-thought-out they are! Thanks for the effort |
This comment has been minimized.
This comment has been minimized.
burdges
commented
Mar 3, 2017
•
|
I'll make time to read these in the next few weeks, but so far my reading beyond the first amounted to ctrl-F "lifetime", but.. I wondered if one could create a value type from a runtime value and lifetime, so that the value acted as basically an implicit parameter, while the lifetime dictates where the proof must resolve. As an example : Imagine we've some crate that requires a struct
I think 3 will become increasingly popular regardless, but const dependent types, or just a fragment there of, makes doing so clean and idiomatic, as opposed to a morass of trait hacks, and they let you avoid unsized types. Now can we push this messy trait based You can nevertheless imagine an implicit parameter being set by a type, and the compiler being asked to prove its correctness, even if under the hood this parameter gets passed at runtime. Can you return a I think 2 actually provides a useful way to imagine these hypothetical "lifetime dependent types". There is some lifetime Apologies for rambling here. |
This comment has been minimized.
This comment has been minimized.
|
sigma types are a part of rust, due to DSTs. |
This comment has been minimized.
This comment has been minimized.
Twey
commented
Mar 14, 2017
|
Hmm, I'm not sure I buy that. |
This comment has been minimized.
This comment has been minimized.
|
Right. From the last time I was confused about this and researched it, I believe there are at least three superficially similar but different beasts in this space: existentials, weak sums, and strong sums. I think "sigma type" applies to both of the latter(?), but that it's usually used to mean strong sums. The difference is best discernible if you have a local variable or a top-level constant of the type, that is, whose definition is also in scope. If we think of each of the three as a pair where the type of the second component may refer to the 'value' of the first, then with existentials, the first component is always erased (even if it's "visible in the source"), and can only be used as an abstract (unknown) value; with weak sums, the first component gives back the same value you put in, but when accessing the second component, its type again refers to an abstract placeholder value in place of the first component; while with strong sums, when you access the second component, its type retains full knowledge of the first's value as well ("dependent elimination"). It's the last of these which is usually referred to as a "dependent pair". So I believe Rust's trait objects correspond to existentials, and its slices to weak sums. (Unfortunately I didn't save the links where I read about this, but if anyone's interested, hopefully googling should lead to the same results.) |
Centril
added
the
T-lang
label
Dec 6, 2017
This comment has been minimized.
This comment has been minimized.
|
Closing this issue since the associated RFCs have all been closed. |
Centril
closed this
Apr 26, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks again @ticki ! This was epic. |
This comment has been minimized.
This comment has been minimized.
YairHalberstadt
commented
Nov 11, 2018
|
This paper might be relevant: It proposes adding a subset of dependant types to a mutable Java-like language by tracking aliases and using move semantics. It can be fully verified at compile time. Any linear inequality over the integers is a valid constraint. As such I think it could fit in with the Rust paradigm very well. |
ticki commentedFeb 26, 2017
•
edited
This issue is reference issue for the upcomming pi type trilogy, dividing the old RFC into 3 parts.
withbounds on pi types.