Scala Collection Framework design

Viewed 68

I'm looking at Scala Collections implementation in 2.12 and have some question about the design. There are some "abstractions types" used in there:

$Coll$Like
Gen$Coll$Like
Gen$Coll$

As far as I understand the Gen$Coll$Like traits exist solely for purpose of reusing declarations (not definitions), i.e. all methods in Gen$Coll$Like traits are abstract.

$Coll$Like in turn declares a few abstract methods and implement the rest of the Gen$Coll$Like methods through them. Besides that $Coll$Like-traits have additional type parameter +Repr which I believe is for cases like SeqLike[Char, String] so we can look at String as Seq[Char].

The most questionable traits are Gen$Coll$. I do not really understand the point of them. In the hierarchy of Seq all Gen$Coll$ traits are empty till GenTraversableOnce (also, I expected GenTraversableOnce to be named GenTraversableOnceLike since it provides abstract method declarations only):

GenSeq <--- GenIterable <--- GenTraversable <--- GenTraversableOnce

Can you explain the purpose of Gen$Coll$ traits? The example of where Gen$Coll$ actually useful (for any purpose) would be highly appreciate.

0 Answers
Related