scala
scala copied to clipboard
Drop covariance?
As pointed by @mechkg, we can drop covariance and obtain a more type-safe interface as a result.
Do we want to keep covariance? I'm tempted to drop it both for the sake of simplification and for better type safety of the graph transformation interface.
As a comparison, List
is covariant, whereas Set
is not.
It is an very interesting design choice to discuss upon and decide. I find no compelling reason for graph to be invariant although as you mentioned it can be done for simplification. Here Daniel's answer gives idea why set is invariant and this thread gives more insights about the design decision.
@adithyaselv Thanks! Yes, after reading various discussions, including the ones you link, I guess we can live with slightly less elegant code for the sake of having covariance, which seems to be expected by default.