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

[PROPOSAL] Either API deprecation, and preparation for 2.x.x #2830

Merged
merged 24 commits into from
Nov 17, 2022
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
More knit fixes..
nomisRev committed Sep 28, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit d5286f7f6b03aac46393d47ded519c774b3760e0
Original file line number Diff line number Diff line change
@@ -805,13 +805,14 @@ public sealed class Either<out A, out B> {
*
* ```kotlin
* import arrow.core.Either
* import io.kotest.matchers.shouldBe
*
* fun main() {
* fun Either<Exception, Int>.computeResult(): Int =
* fold({ error: Exception -> -1 }) { res: Int -> res + 1 }
*
* Either.Right(1).computeResult() shouldBe 2
* Either.Left(RuntimeException("Boom!").computeResult() shouldBe -1
* Either.Left(RuntimeException("Boom!")).computeResult() shouldBe -1
* }
* ```
* <!--- KNIT example-either-34.kt -->
@@ -915,13 +916,9 @@ public sealed class Either<out A, out B> {
* import io.kotest.matchers.shouldBe
*
* fun main() {
* Either.Right(1).tapLeft(::println) shouldBe Either.Right(1)
* Either.Left(2).tapLeft(::println) shouldBe Either.Left(2)
* }
* ```
* ```text
* 2
* ```
* <!--- KNIT example-either-38.kt -->
*/
// TODO open-question: Deprecate for traced ???
@@ -938,12 +935,8 @@ public sealed class Either<out A, out B> {
*
* fun main() {
* Either.Right(1).tap(::println) shouldBe Either.Right(1)
* Either.Left(2).tap(::println) shouldBe Either.Left(2)
* }
* ```
* ```text
* 1
* ```
* <!--- KNIT example-either-39.kt -->
*/
// TODO open-question: deprecate for `bind` ???
@@ -1355,14 +1348,12 @@ public inline fun <B> Either<*, B>.getOrElse(default: () -> B): B =
* or compute a [default] value with the left value [A].
*
* ```kotlin
* import arrow.core.Either.Right
* import arrow.core.Either.Left
* import arrow.core.getOrElse
* import io.kotest.matchers.shouldBe
*
* fun main() {
* Right(12).getOrHandle { it + 5 } shouldBe 12
* Left(12).getOrHandle { it + 5 } shouldBe 17
* Left(12).getOrElse { it + 5 } shouldBe 17
* }
* ```
* <!--- KNIT example-either-45.kt -->
Original file line number Diff line number Diff line change
@@ -2,11 +2,12 @@
package arrow.core.examples.exampleEither34

import arrow.core.Either
import io.kotest.matchers.shouldBe

fun main() {
fun Either<Exception, Int>.computeResult(): Int =
fold({ error: Exception -> -1 }) { res: Int -> res + 1 }

Either.Right(1).computeResult() shouldBe 2
Either.Left(RuntimeException("Boom!").computeResult() shouldBe -1
Either.Left(RuntimeException("Boom!")).computeResult() shouldBe -1
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,5 @@ import arrow.core.Either
import io.kotest.matchers.shouldBe

fun main() {
Either.Right(1).tapLeft(::println) shouldBe Either.Right(1)
Either.Left(2).tapLeft(::println) shouldBe Either.Left(2)
}
Original file line number Diff line number Diff line change
@@ -6,5 +6,4 @@ import io.kotest.matchers.shouldBe

fun main() {
Either.Right(1).tap(::println) shouldBe Either.Right(1)
Either.Left(2).tap(::println) shouldBe Either.Left(2)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// This file was automatically generated from Either.kt by Knit tool. Do not edit.
package arrow.core.examples.exampleEither45

import arrow.core.Either.Right
import arrow.core.Either.Left
import arrow.core.getOrElse
import io.kotest.matchers.shouldBe

fun main() {
Right(12).getOrHandle { it + 5 } shouldBe 12
Left(12).getOrHandle { it + 5 } shouldBe 17
Left(12).getOrElse { it + 5 } shouldBe 17
}