Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Imran Malic Settuba <46971368+i-walker@users.noreply.github.com> Co-authored-by: serras <serras@users.noreply.github.com> Co-authored-by: Imran Malic Settuba <46971368+i-walker@users.noreply.github.com> Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
- Loading branch information
1 parent
ac81bbf
commit 0c50804
Showing
9 changed files
with
251 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eager-effect-scope-08.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
// This file was automatically generated from EagerEffectScope.kt by Knit tool. Do not edit. | ||
package arrow.core.examples.exampleEagerEffectScope08 | ||
|
||
import arrow.core.Either | ||
import arrow.core.None | ||
import arrow.core.Option | ||
import arrow.core.Validated | ||
import arrow.core.continuations.eagerEffect | ||
import arrow.core.continuations.ensureNotNull | ||
import arrow.core.left | ||
import arrow.core.right | ||
import io.kotest.assertions.fail | ||
import io.kotest.matchers.shouldBe | ||
|
||
fun main() { | ||
val failure = "failed" | ||
val int: Int? = null | ||
eagerEffect<String, Int> { | ||
ensureNotNull(int) { failure } | ||
}.toEither() shouldBe (int?.right() ?: failure.left()) | ||
val x = Either.Right(1).bind() | ||
val y = Validated.Valid(2).bind() | ||
val z = | ||
attempt { None.bind { "Option was empty" } } catch { 0 } | ||
x + y + z | ||
}.fold({ fail("Shift can never be the result") }, { it shouldBe 3 }) | ||
} |
16 changes: 16 additions & 0 deletions
16
arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-eager-effect-scope-09.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This file was automatically generated from EagerEffectScope.kt by Knit tool. Do not edit. | ||
package arrow.core.examples.exampleEagerEffectScope09 | ||
|
||
import arrow.core.continuations.eagerEffect | ||
import arrow.core.continuations.ensureNotNull | ||
import arrow.core.left | ||
import arrow.core.right | ||
import io.kotest.matchers.shouldBe | ||
|
||
fun main() { | ||
val failure = "failed" | ||
val int: Int? = null | ||
eagerEffect<String, Int> { | ||
ensureNotNull(int) { failure } | ||
}.toEither() shouldBe (int?.right() ?: failure.left()) | ||
} |
18 changes: 11 additions & 7 deletions
18
arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-scope-09.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
// This file was automatically generated from EffectScope.kt by Knit tool. Do not edit. | ||
package arrow.core.examples.exampleEffectScope09 | ||
|
||
import arrow.core.Either | ||
import arrow.core.None | ||
import arrow.core.Option | ||
import arrow.core.Validated | ||
import arrow.core.continuations.effect | ||
import arrow.core.continuations.ensureNotNull | ||
import arrow.core.left | ||
import arrow.core.right | ||
import io.kotest.assertions.fail | ||
import io.kotest.matchers.shouldBe | ||
|
||
suspend fun main() { | ||
val failure = "failed" | ||
val int: Int? = null | ||
effect<String, Int> { | ||
ensureNotNull(int) { failure } | ||
}.toEither() shouldBe (int?.right() ?: failure.left()) | ||
val x = Either.Right(1).bind() | ||
val y = Validated.Valid(2).bind() | ||
val z = | ||
attempt { None.bind { "Option was empty" } } catch { 0 } | ||
x + y + z | ||
}.fold({ fail("Shift can never be the result") }, { it shouldBe 3 }) | ||
} |
16 changes: 16 additions & 0 deletions
16
arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-scope-10.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This file was automatically generated from EffectScope.kt by Knit tool. Do not edit. | ||
package arrow.core.examples.exampleEffectScope10 | ||
|
||
import arrow.core.continuations.effect | ||
import arrow.core.continuations.ensureNotNull | ||
import arrow.core.left | ||
import arrow.core.right | ||
import io.kotest.matchers.shouldBe | ||
|
||
suspend fun main() { | ||
val failure = "failed" | ||
val int: Int? = null | ||
effect<String, Int> { | ||
ensureNotNull(int) { failure } | ||
}.toEither() shouldBe (int?.right() ?: failure.left()) | ||
} |