Should I use GenSeq by default?

No. The most generic collection types that should appear in APIs are:

  • Seq — sequential collection
  • Set — mathematical sets (no duplicated values)
  • Map — associations / associative sets (conceptually the same as discrete PartialFunctions)

The only abstractions that are neutral to the distinction between the foregoing are Traversable and Iterable. (E.g. Map[K, V] is both Iterable[(K, V)] and Traversable[(K, V)].

If all that matters for an actual parameter is that its elements may be examined in some (unspecified) order, then Traversable captures that characteristic.

Class or trait names that include "Like" or "Once" or "Gen" are part of the internal magic that makes Scala collections exhibit the "principle of least surprise" (chief among them being the property that invoking a HOF upon them such as map or filter yields a result with a matching concrete type as that of the collection upon which that HOF was invoked).


Note you don't need GenSeq anymore with Scala 2.13 (June 2019), considering Parallel collections are now a separate module: scala/scala-parallel-collections

So no more GenSeq (or any Genxxx)

To depend on scala-parallel-collections in sbt, add this to your build.sbt:

libraryDependencies +=
  "org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0"

In your code, adding this import:

import scala.collection.parallel.CollectionConverters._