paulstansifer / unseemly

Macros have types!
http://unseemly.github.io/
MIT License
129 stars 5 forks source link

Handle co/contra/in-variance correctly. #52

Open paulstansifer opened 3 years ago

paulstansifer commented 3 years ago

Currently Cell<Int> is a subtype of forall T . Cell<T>. That's okay. But also Cell<Sequence<Int>> is a subtype of Cell<forall T . Sequence<T>>. That's bad, because you can't actually put a generic sequence into a Cell that wants a sequence of Ints!

I think that a solution looks like this:

So, this might be (part of the) reason why "normal" MLs don't have an explicit forall type (and, I guess, insist that A be defined if you write A<B>): that way you can infer co/contra/in-variance and not have to make a big deal about it. So maybe we should do the normal thing.

paulstansifer commented 2 years ago

Okay, the problem with forall T. T<Int> is that it doesn't have kind annotations (and we don't have a kind-checker yet (#3)). So I think we can get away with just modifying forall. So it's syntax time!

...and, should the annotations be allowed to be omitted (meaning covariance)?