python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Generic Constraint Contravariant Incompatibility in TypeScript
I'm trying to model tagged unions as data.
First I create a Tagged utility type, to represent anything intersected with the tag field:
type Tagged<T, With extends PropertyKey> = T & { _tag: ...
Harry Solovay
Votes: 0
Answers: 1
Does mutation break contravariance in the same way it breaks covariance?
Mutative covariant containers are unsound.
For example, and using no language in particular,
interface Pet;
class Cat extends Pet { meow(); }
class Dog extends Pet { woof(); }
class Box[T] {
value:...
Quelklef
Votes: 0
Answers: 0
Contravariant interfaces method dispatch/selection C#
Consider the following code:
interface ITest<in T>
{
void DoTest(T instance);
}
class A {}
class B : A {}
class C : B {}
class Test : ITest<A>, ITest<B>
{
void ITest<A&g...
Valentino Miori
Votes: 0
Answers: 1
Why can't I take a contravariant interface as a parameter to a method on the interface?
I'm trying to setup a CoR with interfaces where a handler in the chain can be a for a less derived event type using contravariance. I create this interface to do it.
public interface IHandler<in TE...
just.another.programmer
Votes: 0
Answers: 1