Closed github-actions[bot] closed 4 years ago
https://github.com/arrow-kt/arrow/commit/b4ed45617c44def217f2ac0cacb836624fa1f008/checks
diff --cc gradle.properties index 81c0306e3,cd0617f0b..000000000 --- a/gradle.properties +++ b/gradle.properties @@@ -1,19 -1,37 +1,43 @@@ # Package definitions GROUP=io.arrow-kt ++<<<<<<< HEAD +VERSION_NAME=0.11.0-SNAPSHOT +# Other versions +KOTLIN_VERSION=1.3.50 ++======= + VERSION_NAME=0.10.5-SNAPSHOT + # Versions + ANIMALS_SNIFFER_VERSION=1.5.0 + ATOMICFU_VERSION=0.13.2 + BINTRAY_PLUGIN_VERSION=1.8.4 + BUILD_TIME_TRACKER_VERSION=0.11.1 + CATS_EFFECT_VERSION=2.0.0 + CLASSGRAPH_VERSION=4.8.14 + DEV_ZIO_VERSION=1.0.0-RC17 ++>>>>>>> origin/master DOKKA_VERSION=0.10.0 - KTLINT_VERSION=0.34.2 - KTLINT_GRADLE_VERSION=8.2.0 + GIT_PUBLISH_VERSION=2.1.3 + GOOGLE_AUTO_SERVICE_VERSION=1.0-rc4 + GOOGLE_COMPILE_TESTING_VERSION=0.15 GRADLE_VERSIONS_PLUGIN_VERSION=0.21.0 + JACKSON_MODULE_KOTLIN_VERSION=2.9.7 + JAVA_VERSION=1.7 + JMH_CORE_VERSION=1.22 + JMH_PLUGIN_VERSION=0.5.0 + JMH_REPORT_PLUGIN_VERSION=0.9.0 JUNIT_VERSION=4.12 JUNIT_VINTAGE_VERSION=5.5.2 - JAVA_VERSION=1.7 + KINDEDJ_VERSION=1.1.0 + KOTLIN_METADATA_VERSION=1.4.0 KOTLIN_POET_VERSION=1.1.0 KOTLIN_TEST_VERSION=3.3.3 + KOTLIN_VERSION=1.3.50 KOTLINX_COLLECTIONS_IMMUTABLE_VERSION=0.1 KOTLINX_COROUTINES_VERSION=1.3.3 + KTLINT_GRADLE_VERSION=8.2.0 + KTLINT_VERSION=0.34.2 + MOCKWEBSERVER_VERSION=3.13.1 + MSEC_KIO_VERSION=0.3 PROJECT_REACTOR_VERSION=3.2.6.RELEASE RETROFIT_VERSION=2.5.0 RX_JAVA_VERSION=2.2.13 diff --cc modules/fx/arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt index 6afc7e5ea,5ae0c77da..000000000 --- a/modules/fx/arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt +++ b/modules/fx/arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt @@@ -1,17 -1,14 +1,22 @@@ package arrow.integrations.kotlinx -import arrow.core.Either -import arrow.core.right -import arrow.core.some +import arrow.core.Right +import arrow.core.Some import arrow.fx.IO +import arrow.fx.IOResult import arrow.fx.extensions.fx ++<<<<<<< HEAD +import arrow.fx.extensions.io.async.effectMap +import arrow.fx.flatMap +import arrow.fx.onCancel ++======= + import arrow.fx.handleErrorWith + import arrow.fx.extensions.io.bracket.onCancel ++>>>>>>> origin/master import arrow.fx.typeclasses.milliseconds import arrow.fx.typeclasses.seconds +import arrow.fx.unsafeRunAsync +import arrow.fx.unsafeRunSync import arrow.test.UnitSpec import arrow.test.generators.throwable import io.kotlintest.fail diff --cc modules/fx/arrow-fx/src/main/kotlin/arrow/fx/IOConnection.kt index 61ba1a3e7,754433719..000000000 --- a/modules/fx/arrow-fx/src/main/kotlin/arrow/fx/IOConnection.kt +++ b/modules/fx/arrow-fx/src/main/kotlin/arrow/fx/IOConnection.kt @@@ -29,80 -15,32 +29,99 @@@ internal class IOContext(val connection companion object Key : CoroutineContext.Key<IOContext> } -@Suppress("UNUSED_PARAMETER", "FunctionName") -fun IOConnection(dummy: Unit = Unit): IOConnection = KindConnection(MD) { it.fix().unsafeRunAsync { } } +internal sealed class IOConnection { + + abstract fun cancel(): IOOf<Nothing, Unit> + abstract fun isCancelled(): Boolean + fun isNotCancelled(): Boolean = !isCancelled() + abstract fun <E> push(token: IOOf<E, Unit>): Unit + abstract fun <E> push(vararg token: IOOf<E, Unit>): Unit + fun pushPair(lh: IOConnection, rh: IOConnection): Unit = push(lh.cancel(), rh.cancel()) + fun <E, E2> pushPair(lh: IOOf<E, Unit>, rh: IOOf<E2, Unit>): Unit = push(lh, rh) + abstract fun pop(): IOOf<Nothing, Unit> + abstract fun tryReactivate(): Boolean + + fun toDisposable(): Disposable = { + cancel().fix().unsafeRunSync() + } + + companion object { + val uncancellable: IOConnection = Uncancellable + operator fun invoke(): IOConnection = DefaultConnection() + } +} + +private object Uncancellable : IOConnection() { + override fun cancel(): IOOf<Nothing, Unit> = IO.unit + override fun isCancelled(): Boolean = false + override fun <E> push(token: IOOf<E, Unit>): Unit = Unit + override fun <E> push(vararg token: IOOf<E, Unit>): Unit = Unit + override fun pop(): IOOf<Nothing, Unit> = IO.unit + override fun tryReactivate(): Boolean = true + override fun toString(): String = "UncancellableConnection" +} -private val _uncancelable = KindConnection.uncancelable(MD) -internal inline val KindConnection.Companion.uncancelable: IOConnection - inline get() = _uncancelable +private class DefaultConnection : IOConnection() { + private val state: AtomicRef<List<IOOf<Nothing, Unit>>?> = atomic(emptyList()) + override fun cancel(): IOOf<Nothing, Unit> = IO.defer { + state.getAndSet(null).let { stack -> + when { + stack == null || stack.isEmpty() -> IO.unit + else -> stack.cancelAll() + } + } + } + ++<<<<<<< HEAD + override fun isCancelled(): Boolean = state.value == null + + override tailrec fun <E> push(token: IOOf<E, Unit>): Unit = when (val list = state.value) { + // If connection is already cancelled cancel token immediately. + null -> token.rethrow.unsafeRunSync() + else -> if (!state.compareAndSet(list, listOf(token.rethrow) + list)) push(token) else Unit + } ++======= + private object MD : MonadDefer<ForIO> { + override fun <A> defer(fa: () -> IOOf<A>): IO<A> = + IO.defer(fa) + + override fun <A> raiseError(e: Throwable): IO<A> = + IO.raiseError(e) ++>>>>>>> origin/master - override fun <A> IOOf<A>.handleErrorWith(f: (Throwable) -> IOOf<A>): IO<A> = - handleErrorW(f) + override fun <E> push(vararg token: IOOf<E, Unit>): Unit = + push(token.toList().cancelAll()) ++<<<<<<< HEAD + override tailrec fun pop(): IOOf<Nothing, Unit> { + val state = state.value + return when { + state == null || state.isEmpty() -> IO.unit + else -> if (!this.state.compareAndSet(state, state.drop(1))) pop() + else state.first() + } + } ++======= + override fun <A> just(a: A): IO<A> = + IO.just(a) ++>>>>>>> origin/master - override fun <A, B> IOOf<A>.flatMap(f: (A) -> IOOf<B>): IO<B> = - fix().flatMap(f) + override fun tryReactivate(): Boolean = + state.compareAndSet(null, emptyList()) ++<<<<<<< HEAD + private fun <E> List<IOOf<E, Unit>>.cancelAll(): IOOf<Nothing, Unit> = IO.defer { + // TODO this blocks forever if any `CancelToken<F>` doesn't terminate. Requires `fork`/`start` to avoid. + fold(IO.unit) { acc, f -> f.flatMap { acc } } + } ++======= + override fun <A, B> tailRecM(a: A, f: (A) -> IOOf<Either<A, B>>): IO<B> = + IO.tailRecM(a, f) ++>>>>>>> origin/master - override fun <A, B> IOOf<A>.bracketCase(release: (A, ExitCase<Throwable>) -> IOOf<Unit>, use: (A) -> IOOf<B>): IO<B> = - fix().bracketCase(release = { a, e -> release(a, e).fix() }, use = { use(it).fix() }) + override fun toString(): String = "KindConnection(state = ${state.value})" } + +internal val <E, A> IOOf<E, A>.rethrow: IO<Nothing, A> + get() = handleErrorWith({ t -> IO.raiseException<Nothing>(t) }, { e -> IO.raiseException(UnhandledError(e)) }) diff --cc modules/fx/arrow-fx/src/main/kotlin/arrow/fx/extensions/io.kt index 73920f7bc,c3c416a0f..000000000 --- a/modules/fx/arrow-fx/src/main/kotlin/arrow/fx/extensions/io.kt +++ b/modules/fx/arrow-fx/src/main/kotlin/arrow/fx/extensions/io.kt @@@ -2,24 -2,18 +2,28 @@@ package arrow.fx.extension import arrow.Kind import arrow.core.Either -import arrow.core.identity +import arrow.core.Left +import arrow.core.Right import arrow.extension ++<<<<<<< HEAD ++======= + import arrow.fx.ForIO ++>>>>>>> origin/master import arrow.fx.IO +import arrow.fx.IOPartialOf +import arrow.fx.IOResult +import arrow.fx.typeclasses.ExitCase2 import arrow.fx.IODispatchers import arrow.fx.IOOf +import arrow.fx.MVar import arrow.fx.OnCancel +import arrow.fx.Promise import arrow.fx.RacePair import arrow.fx.RaceTriple +import arrow.fx.Semaphore import arrow.fx.Timer -import arrow.fx.extensions.io.concurrent.concurrent import arrow.fx.extensions.io.dispatchers.dispatchers +import arrow.fx.extensions.io.concurrent.concurrent import arrow.fx.fix import arrow.fx.typeclasses.Async import arrow.fx.typeclasses.Bracket diff --cc modules/fx/arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt index 58290b134,206c0e78e..000000000 --- a/modules/fx/arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt +++ b/modules/fx/arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt @@@ -907,10 -837,9 +907,18 @@@ internal fun <E> IO.Companion.eqK() = o } } ++<<<<<<< HEAD +private fun IO.Companion.genK() = object : GenK<IOPartialOf<Nothing>> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<IOPartialOf<Nothing>, A>> = + Gen.oneOf( + gen.map(IO.Companion::just), + Gen.throwable().map { raiseException<A>(it) } + ) ++======= + internal fun IO.Companion.genK() = object : GenK<ForIO> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<ForIO, A>> = Gen.oneOf( + gen.map(IO.Companion::just), + Gen.throwable().map(IO.Companion::raiseError) + ) ++>>>>>>> origin/master } * Unmerged path modules/docs/arrow-docs/docs/docs/arrow-core/integrations/kotlinxcoroutines/README.md
Closed by 3715a057855c969a2e8c2f7a2f001c663d781f3a
Error log
https://github.com/arrow-kt/arrow/commit/b4ed45617c44def217f2ac0cacb836624fa1f008/checks
Conflicts