Implementation of the new collections of Scala 2.13.
The new collections are available as a regular external library (see below usage
instructions). The collections live in the strawman.collection
namespace
(instead of scala.collection
).
Almost all operations and collection types of the current standard collections are available. If you see something missing, please create an issue.
The new collections will be part of the 2.13.0-M4 Scala distribution, where they will replace the standard collections.
Add the following dependency to your project:
libraryDependencies += "ch.epfl.scala" %% "collection-strawman" % "0.9.0"
libraryDependencies += "ch.epfl.scala" %% "collections-contrib" % "0.9.0" // optional
The 0.9.0 version is compatible with Scala 2.13 and Dotty 0.6. Scala 2.12 is also supported but you might encounter type inference issues with it.
We also automatically publish snapshots on Sonatype:
resolvers += Resolver.sonatypeRepo("snapshots")
libraryDependencies += "ch.epfl.scala" %% "collection-strawman" % "0.10.0-SNAPSHOT"
The collections-contrib
artifact provides additional operations on the collections (see the
Additional operations section).
There is an entry in the FAQ that aims to list all breaking changes.
A tool is being developed to automatically migrate code that uses the standard collection to use the strawman.
To use it, add the scalafix sbt plugin to your build, as explained in its documentation.
Two situations are supported: (1) migrating a 2.12 code base to a 2.12 code base that uses the collection strawman as a library (instead of the standard collections), and (2) migrating a 2.12 code base to 2.13 code base.
The migration tool is not exhaustive and we will continue to improve it over time. If you encounter a use case that’s not supported, please report it as described in the contributing documentation.
Run the following sbt task on your project:
> scalafix https://github.com/scala/collection-strawman/raw/master/scalafix/2.12/rules/src/main/scala/fix/Collectionstrawman_v0.scala
In essence, the migration tool changes the imports in your source code so that the strawman definitions are imported. It also rewrites expressions that use an API that is different in the strawman.
Run the following sbt task on your project:
> scalafix https://github.com/scala/collection-strawman/raw/master/scalafix/2.13/rules/src/main/scala/fix/Collectionstrawman_v0.scala
We welcome contributions!
For more information, see the CONTRIBUTING file.