Ah the collections hierarchy, always a joy to debug type errors related to it.
The problem here is not the Seq.empty[A], that is actually fine and works as expected since patch is able to receive any IterableOnce.
The problem is actually that patch here is returning a Seq[A] rather than a CC[A] as you want.
I fixed it by mixing the SeqOps to the type signature:
I’ll have a look. It’s interesting that Map has an updatedWith that is exactly what I need here (update or remove based on an option). I was surprised not to find it on IndexedSeq.
I think your first attempt was closer, because deletion does not introduce a new element type, so it should return a C like (checks notes) diff does.
The doc explains that CC is for when the element type changes (widens), and C is what you started with.
But in an extension, you can’t call fromSpecific because that’s why we can’t have nice things.
For example, this is weirdly natural:
scala> "1234".diff("3")
val res0: String = 124
Thanks to SethTisue and BalmungSan, I added scala to my triple backtick, and it seems to render better. I’m not sure what the colors mean, but there is no extravagant boldface.