Skip to content

Commit e3e9b00

Browse files
authored
Merge pull request #358 from SethTisue/overhaul-readme
overhaul README.md
2 parents 167833d + b425e2c commit e3e9b00

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
11
[![Build Status](https://travis-ci.org/scala/scala-collection-compat.svg?branch=master)](https://travis-ci.org/scala/scala-collection-compat)
22

3-
# Scala 2.13 Collection Compatibility Library And Migration Tool
3+
## Purpose and scope
44

5-
## Compatibility Library
5+
This library makes some Scala 2.13 APIs available on Scala 2.11 and 2.12.
66

7-
This library provides some of the new APIs from Scala 2.13 to Scala 2.11 and 2.12. It can be used to cross-build projects.
8-
To use this library, add the following to your build.sbt:
7+
The idea is to facilitate
8+
[cross-building](https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213)
9+
Scala 2.13 code on the older versions.
10+
11+
Although the name of the library is scala-"collection"-compat, we have now widened the scope to include other parts of the Scala 2.13 standard library besides just collections.
12+
13+
Only the most commonly used APIs are supported; many are missing. Contributions are welcome.
14+
15+
## Usage
16+
17+
To use this library, add the following to your `build.sbt`:
918

1019
```
1120
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6"
1221
```
1322

14-
Version 2.0.0+ is compatible with Scala 2.13, 2.12, and 2.11.
23+
Exception: the 1.0.0 release was withdrawn and should not be used.
1524

16-
Note that there are multiple ways to cross-build projects, see https://github.com/scala/collection-strawman/wiki/FAQ#how-do-i-cross-build-my-project-against-scala-212-and-scala-213.
25+
All future versions will remain backwards binary compatible with 2.0.0+.
1726

18-
**Note**: Please do not release any artifacts against version 1.0.0, due to [#195](https://github.com/scala/scala-collection-compat/issues/195).
27+
## How it works
1928

20-
Backwards binary compatibility will be enforced within each major version (i.e. all 1.x.y releases will be binary compatible).
29+
The 2.13 collections redesign did not break source compatibility for much ordinary code, there are exceptions.
2130

22-
The 2.13 collections are mostly backwards source-compatible, but there are some exceptions. For example, the `to` method is used with a type parameter in 2.12:
31+
For example, the `to` method is used with a type parameter in 2.12:
2332

2433
```scala
25-
xs.to[List]
34+
xs.to[List]
2635
```
2736

28-
With this compatibility library you can also use the 2.13 syntax which uses a companion object:
37+
With this compatibility library you can instead use the 2.13 syntax, which takes a value parameter:
2938

3039
```scala
31-
import scala.collection.compat._
32-
xs.to(List)
40+
import scala.collection.compat._
41+
xs.to(List)
3342
```
3443

3544
The 2.13 version consists only of an empty `scala.collection.compat` package object that allows you to write `import scala.collection.compat._` in 2.13.
36-
The 2.11/2.12 version has the compatibility extensions in this package.
3745

38-
The library also adds backported versions of new collection types, currently `scala.collection.compat.immutable.ArraySeq`. In 2.11/2.12, this type is a new collection implementation. In 2.13, it is an alias for `scala.collection.immutable.ArraySeq`.
46+
The 2.11 and 2.12 versions have the needed compatibility code in this package.
3947

40-
## Migration Tool
48+
The library also adds backported versions of new collection types, such as `immutable.ArraySeq` and `immutable.LazyList`. (On 2.13, these types are just aliases to standard library types.)
4149

42-
The migration rules use scalafix. Please see the [official installation instruction](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.12).
50+
And it adds backported versions of some 2.13 collections methods such as `maxOption`.
51+
52+
And, it includes support for some non-collections classes such as the `@nowarn` annotation added in 2.13.2.
53+
54+
## Migration rules
55+
56+
The migration rules use scalafix. Please see the [official installation instructions](https://scalacenter.github.io/scalafix/docs/users/installation.html) and, in particular, check that your full Scala version is supported (ex 2.12.12).
4357

4458
```scala
4559
// project/plugins.sbt
@@ -64,7 +78,6 @@ scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on")
6478

6579
### Collection213CrossCompat
6680

67-
6881
The `Collection213CrossCompat` rewrite upgrades to the 2.13 collections with the ability to compile the code-base with 2.12 or later. This rewrite is suitable for libraries that are cross-published for multiple Scala versions.
6982

7083
To cross-build for 2.12 and 2.11, the rewrite rule introduces a dependency on the scala-collection-compat module, which provides the syntax of 2.13 on 2.12 and 2.11. This enables you to write your library using the latest 2.13 collections API while still supporting users on an older Scala version.

0 commit comments

Comments
 (0)