parTupled

inline suspend fun <A, B> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B): Pair<A, B>

Runs fa, fb in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple


inline suspend fun <A, B, C> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C): Triple<A, B, C>

Runs fa, fb, fc in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result: Triple<String, String, String> = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple


inline suspend fun <A, B, C, D> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D): Tuple4<A, B, C, D>

Runs fa, fb, fc, fd in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple


inline suspend fun <A, B, C, D, E> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E): Tuple5<A, B, C, D, E>

Runs fa, fb, fc, fd, fe in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple

fe

value to parallel tuple


inline suspend fun <A, B, C, D, E, F> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F): Tuple6<A, B, C, D, E, F>

Runs fa, fb, fc, fd, fe, ff in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple

fe

value to parallel tuple

ff

value to parallel tuple


inline suspend fun <A, B, C, D, E, F, G> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G): Tuple7<A, B, C, D, E, F, G>

Runs fa, fb, fc, fd, fe, ff, fg in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" },
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple

fe

value to parallel tuple

ff

value to parallel tuple

fg

value to parallel tuple


inline suspend fun <A, B, C, D, E, F, G, H> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H): Tuple8<A, B, C, D, E, F, G, H>

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" },
{ "Eighth one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple

fe

value to parallel tuple

ff

value to parallel tuple

fg

value to parallel tuple

fh

value to parallel tuple


inline suspend fun <A, B, C, D, E, F, G, H, I> parTupled(context: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend CoroutineScope.() -> A, crossinline fb: suspend CoroutineScope.() -> B, crossinline fc: suspend CoroutineScope.() -> C, crossinline fd: suspend CoroutineScope.() -> D, crossinline fe: suspend CoroutineScope.() -> E, crossinline ff: suspend CoroutineScope.() -> F, crossinline fg: suspend CoroutineScope.() -> G, crossinline fh: suspend CoroutineScope.() -> H, crossinline fi: suspend CoroutineScope.() -> I): Tuple9<A, B, C, D, E, F, G, H, I>

Runs fa, fb, fc, fd, fe, ff, fg, fh, fi in parallel on ctx and combines their results as a tuple.

Coroutine context is inherited from caller, additional context elements can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parTupled(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" },
{ "Eighth one is on ${Thread.currentThread().name}" },
{ "Ninth one is on ${Thread.currentThread().name}" }
)
//sampleEnd
println(result)
}

Parameters

fa

value to parallel tuple

fb

value to parallel tuple

fc

value to parallel tuple

fd

value to parallel tuple

fe

value to parallel tuple

ff

value to parallel tuple

fg

value to parallel tuple

fh

value to parallel tuple

fi

value to parallel tuple