Hacker News new | past | comments | ask | show | jobs | submit login

With dependent types, each `e.key` has it's own and separate type. So, if you have two `e`s, the type of the first e's key will not match the type of the second e's key.

So, with:

def process(p: Path, key: p.Key): Something = ???

this will not compile:

val p1: Path = ???

val p2: Path = ???

process(p1, p2.key) <- compile-time-error




Interesting. Thanks!

I've been using a lot of Swift lately, and they have a generic type roadmap that talks about "existential types" and being able to "open" an existential. This looks very similar.


I don't know about in Swift, but in programming languages in general, existential types are usually a concept different from dependent types.[0]

[0] https://stackoverflow.com/questions/292274/what-is-an-existe...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: