|
|
|
|
|
by pansa2
442 days ago
|
|
> > For function parameters, doesn't it depend on how the parameter is used? > I don't think so, but maybe there's specific circumstances I don't know of? I don't know specific circumstances either, but I presume they exist because of things like Dart's `covariant` keyword [0], which makes function parameters covariant instead of contravariant. [0] https://dart.dev/language/type-system#covariant-keyword |
|
Consider if we have `A <= B <= C`, and a function:
Given some potential inputs: The following should be true: If the `dest` argument were contravariant, it would permit invalid copies and forbid valid ones. In a purely functional setting, you should not need a covariant parameter type because all writes would end up in the return type.