Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build docs on 2.13 #4238

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
java: [temurin@8, temurin@17, graalvm@11]
project: [rootJS, rootJVM, rootNative]
exclude:
- scala: 2.13.8
- scala: 2.12.16
java: temurin@17
- scala: 2.13.8
- scala: 2.12.16
java: graalvm@11
- scala: 3.1.2
java: temurin@17
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.16]
scala: [2.13.8]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -262,32 +262,32 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.12.16, rootJVM)
- name: Download target directories (2.13.8, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS

- name: Inflate target directories (2.12.16, rootJVM)
- name: Inflate target directories (2.13.8, rootJS)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.12.16, rootJVM)
- name: Download target directories (2.13.8, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM

- name: Inflate target directories (2.12.16, rootJVM)
- name: Inflate target directories (2.13.8, rootJVM)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8, rootJS)
- name: Download target directories (2.13.8, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative

- name: Inflate target directories (2.13.8, rootJS)
- name: Inflate target directories (2.13.8, rootNative)
run: |
tar xf targets.tar
rm targets.tar
Expand All @@ -302,12 +302,12 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8, rootNative)
- name: Download target directories (2.13.8, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM

- name: Inflate target directories (2.13.8, rootNative)
- name: Inflate target directories (2.13.8, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
Expand Down Expand Up @@ -361,7 +361,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.16]
scala: [2.13.8]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -440,7 +440,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.16]
scala: [2.13.8]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ val Scala213 = "2.13.8"
val Scala3 = "3.1.2"

ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / scalaVersion := Scala212
ThisBuild / scalaVersion := Scala213

ThisBuild / tlFatalWarnings := false
ThisBuild / tlFatalWarningsInCi := false
Expand Down
2 changes: 1 addition & 1 deletion docs/datatypes/writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ applies a bunch of Math operations, logging each one of them.
import cats.data.Writer
import scala.math.sqrt

val writer1: Writer[String, Double] = Writer.value(5.0).tell("Initial value ")
val writer1: Writer[String, Double] = Writer.value[String, Double](5.0).tell("Initial value ")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a type inference regression from 2.12 -> 2.13.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems so... I think it might be nice (in the future) to create a better version of Writer.value (and WriterT.value) with some sort of PartialApply involved which would allow to write something line this:

val writer1 = Writer.value[String](5.0).tell("Initial value ")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we can do it bincompatibly probably but it would be source-breaking...

val writer2: Writer[String, Double => Double] = Writer("sqrt ", (i: Double) => sqrt(i))
val writer3: Double => Writer[String, Double] = (x: Double) => Writer("add 1 ", x + 1)
val writer4: Writer[String, Double => Double] = Writer("divided by 2 ", (x: Double) => x / 2)
Expand Down
20 changes: 8 additions & 12 deletions docs/typeclasses/foldable.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,25 @@ which are lazy in their right hand argument to traverse the entire
structure unnecessarily. For example, if you have:

```scala mdoc
val allFalse = Stream.continually(false)
val allFalse = LazyList.continually(false)
```

which is an infinite stream of `false` values, and if you wanted to
which is an infinite list of `false` values, and if you wanted to
reduce this to a single false value using the logical and (`&&`). You
intuitively know that the result of this operation should be
`false`. It is not necessary to consider the entire stream in order to
`false`. It is not necessary to consider the entire list in order to
determine this result, you only need to consider the first
value. Using `foldRight` from the standard library *will* try to
consider the entire stream, and thus will eventually cause a stack
overflow:
consider the entire list, and thus will eventually cause an out-of-memory error:

```scala mdoc
try {
allFalse.foldRight(true)(_ && _)
} catch {
case e:StackOverflowError => println(e)
}
```scala
// beware! throws OutOfMemoryError, which is irrecoverable
allFalse.foldRight(true)(_ && _)
```
Comment on lines -117 to 119
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to throw OutOfMemoryError instead of StackOverflowError on my machine. Maybe in 2.13 they made it stack-safe?

Problem is, unlike StackOverflowError, I believe an OutOfMemoryError is irrecoverable, so a try/catch here only leads to problems arising elsewhere in the JVM. At least that's what I was observing locally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to save time for other curious readers :)

Specialized implementation of reverse in LazyList in Scala 2.13 is now @tailrec
https://github.com/scala/scala/blob/bfe46ae4da6401a62c83b728561d6bc7d1b3467b/src/library/scala/collection/immutable/LazyList.scala#L735


With the lazy `foldRight` on `Foldable`, the calculation terminates
after looking at only one value:

```scala mdoc
Foldable[Stream].foldRight(allFalse, Eval.True)((a,b) => if (a) b else Eval.False).value
Foldable[LazyList].foldRight(allFalse, Eval.True)((a,b) => if (a) b else Eval.False).value
```
2 changes: 1 addition & 1 deletion docs/typeclasses/nonemptytraverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import cats.data.NonEmptyList
val snippets = NonEmptyList.of("What do you do", "What are you doing")

def countWords(text: String): Map[String, Int] =
text.split(" ").groupBy(identity).mapValues(_.length)
text.split(" ").groupBy(identity).mapValues(_.length).toMap
armanbilge marked this conversation as resolved.
Show resolved Hide resolved

snippets.nonEmptyTraverse(countWords)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/typeclasses/reducible.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Reducible[NonEmptyList].reduceLeftTo(NonEmptyList.of(1,2,3,4))(_.toString)((s,i)
Reducible[NonEmptyList].reduceRightTo(NonEmptyList.of(1,2,3,4))(_.toString)((i,s) => Later(s.value + i)).value
Reducible[NonEmptyList].nonEmptyIntercalate(NonEmptyList.of("a", "b", "c"), ", ")

def countChars(s: String) = s.toCharArray.groupBy(identity).mapValues(_.length)
def countChars(s: String) = s.toCharArray.groupBy(identity).mapValues(_.length).toMap
armanbilge marked this conversation as resolved.
Show resolved Hide resolved

Reducible[NonEmptyList].nonEmptyTraverse_(NonEmptyList.of("Hello", "World"))(countChars)
Reducible[NonEmptyVector].nonEmptyTraverse_(NonEmptyVector.of("Hello", ""))(countChars)
Expand Down