unseemly
unseemly copied to clipboard
Allow subtyping at the syntax level
In order to use generics, we need subtyping. So an apply macro, instead of demanding that the function be of type [I -> O], should demand that it be a subtype of that. We definitely don't want this to be the case for all syntax arguments, so we need an explicit way of writing this. (also, we presumably will want the reverse at some point)
Would it be possible to just have a AnySubtypeOf<T> type? Surely that can't work...
I had thought that reversing might be doable by marking some type variables of a macro definition as covariant and some as contravariant. That won't work! You might have something of type Int and still want to allow subtyping.
Also: it's not the apply macro that needs reversal at all! If you have Expr<[I -> O]> and Expr<I> and put them together with covariant subtyping, everything works fine (the function type has contravariance inside it, which is just fine). It's the function definition macro that needs contravariance. Aha! While Expr<Cat> is a subtype of Expr<Pet>, Pat<Pet> is a subtype of Pat<Cat>. So all that matters is whether the NT is negative or not.
This should be a piece of cake.