than_
08/21/2020, 9:40 AMCould not find arrow-fx-0.11.0-SNAPSHOT.jar (io.arrow-kt:arrow-fx:0.11.0-SNAPSHOT:20200821.081149-114).
Searched in the following locations:
<https://oss.jfrog.org/artifactory/oss-snapshot-local/io/arrow-kt/arrow-fx/0.11.0-SNAPSHOT/arrow-fx-0.11.0-20200821.081149-114.jar>
Looking here that seems to be correct. Last snapshot has only pom, sources and javadoc files available.Gopal S Akshintala
08/21/2020, 11:14 AM<https://next.arrow-kt.io/docs/fx/async/>
<https://arrow-kt.io/docs/next/fx/async/>
Gopal S Akshintala
08/21/2020, 1:00 PMparTraverse
uses fibers underneath, how can I see that effect apart from measuring time (like by printing Fiber-id or something). I tried this example:
@Test
fun `parTraverse + blocking`() {
val time = measureTimeMillis {
runBlocking {
(1..20).parTraverse {
blockingWork(it)
}
}
}
// 3s, multiple blocked bg threads
println("Done in $time ms [${Thread.currentThread().name}]")
}
Gopal S Akshintala
08/22/2020, 8:39 AMeither{}
DSL. The return type of this is Either<E,A>
, so I understand one way the composition trips to left
is -- one of the functions inside returns an either in left
I am unable to figure out how to explicitly return an either in left
from within the block.
For example:
val result: Either<String, String> = either { // This casts the side-effect function into a suspend function.
val id = !getSomethingFromDb(true)
val data = !getSomethingElseFromNetwork(id)
val either = if (data.isEmpty()) {
// vvv how to return either on left
!"SOME_CUSTOM_ERROR".raiseError()
} else data.right()
either
}
I understand for a case like this where I have this requirement on the last step, I can return from outside the block, but just curious how to short-circuit from the middle of the block?julian
08/23/2020, 6:48 PMOption
map2
, one provides a lambda that handles the case where both values are Some
. But what if one wants to provide a lambda for all four possible cases? I can do this from scratch. But I wondered if there's a higher order function in Arrow that's already designed for this.Gopal S Akshintala
08/24/2020, 4:03 AMIOPool
in conjunction with parTraverse
in the right way? I couldn't find any documentation about it.
@Test
fun `IODispatcher + parTraverse + blocking`() {
val time = measureTimeMillis {
runBlocking {
evalOn(IODispatchers.IOPool) {
(1..20).parTraverse {
blockingWork(it)
}
}
}
}
println("Done in $time ms [${Thread.currentThread().name}]")
}
private fun blockingWork(i: Int) {
Thread.sleep(1000)
println("Work $i done [${Thread.currentThread().name}]")
}
Alexander Schell
08/25/2020, 8:13 AMHieiJ
08/26/2020, 12:23 PMisto
08/27/2020, 12:27 PMmapN
takes in at most 10 params (0.10.5), any tips how to workaround a case where there's more than 10julian
08/28/2020, 4:05 AMState
and saw this:
fun <S, T, P1, R> State<S, T>.map(sx: State<S, P1>, f: (T, P1) -> R): State<S, R> =
flatMap(IdBimonad) { t -> sx.map { x -> f(t, x) } }.fix()
What is IdBimonad
doing?
(I read the docs available for BiMonad
, but I'm still mystified.)Maciek
08/28/2020, 11:49 AMEither
as return type? Or is there some different suggested way of handling retrofit calls?Johan Basson
08/28/2020, 1:00 PMjulian
08/28/2020, 5:43 PMarrow-core
and run ./gradlew build
, I get this error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/bayo/dev/arrow-core/build.gradle' line: 2
* What went wrong:
A problem occurred evaluating root project 'arrow-core-lib'.
> Could not read '<https://raw.githubusercontent.com/arrow-kt/arrow/master/setup.gradle>' as it does not exist.
What am I doing wrong?
I just want to be able to open and explore the source with all the features of IntelliJ that assist that to be available.zero_coding
08/29/2020, 3:59 PMfun Program.handleRead(id: String?): UserMapper =
id?.let {
UUID.fromString(it)?.let { uuid ->
queries.read(uuid)?.toMapper()
} ?: throw UUIDWrongFormatException()
} ?: throw UserNotFoundException()
zero_coding
08/30/2020, 1:15 PMplugins {
application
kotlin("jvm") version "1.4.0"
?????
}
Would be nice if someone could help.zero_coding
08/30/2020, 4:33 PMtrait GenderQuery[F[_]] {
def findAll: F[Genders]
}
CLOVIS
08/31/2020, 1:27 PMJohan Basson
09/01/2020, 9:43 AMtypealias GetCustomer = (config: Config, domain: Domain) -> IO<Either<ApiError, Option<CustomerDetails>>>
which will do a rest call to get CustomerDetails
Reading the arrow documentation i managed to get this:
val io = getCustomer(cloudConfig, domain).repeat(IO.concurrent(), Schedule.doWhile(IO.monad()) { it.isEmpty()})
val maybeCustomer = EitherT(io).bind()
How can i add exponential backoff with a max retries of 10 starting with a 1 second delay?Ryan Benasutti
09/01/2020, 10:16 PMsuspend
versions of map
and flatMap
for Either
?gas
09/02/2020, 8:02 AMrcd27
09/02/2020, 8:09 AMJohan Basson
09/02/2020, 9:04 AMthan_
09/02/2020, 10:52 AMYoussef Shoaib [MOD]
09/05/2020, 7:28 PMjust
be implemented for any Functor by using an instance of that functor and calling map on it with a function that disregards it's results and just returns whatever value was passed in. So something like this
inline fun <reified F,A,B> Kind<F,A>.Companion.just(value: B): Kind<F,B> {
return getSomeStaticValueForFunctor<F>().map { B }
}
So instead of having Applicative, couldn't there be just a FunctorWithStaticInstance
that then Apply
inherits from (and by extension Monad
also inherits from). Additonally, the docs mention that some classes can implement Apply
but not Applicative
, but isn't it guaranteed that every typeclass in general will have an instance? so then with a pretty simple implementation you could probably produce a Functor<Unit>
that will be a val
on FunctorWithStaticInstance
. Or maybe even every functor could just have a static instance by default. Maybe then you could even have just
on Functor
itself. I'm sure that there's definitely something wrong with my reasoning, but I honestly cannot figure it out.Hiosdra
09/06/2020, 7:31 PM@GET("foo")
suspend fun getFoo(
@Query("param") param: String
): Either<Unit, FooDto>
and helper (ideally unnecessary) method:
fun notGonnaHappenError(): Throwable = TODO()
How to return Either<DomainError, FooDto>
?
I have this method:
private suspend fun getFoo(param: Bar): Either<DomainError, FooDto> =
Either.catch { client.getFoo(param.value).mapLeft { notGonnaHappenError() } }
.flatten()
.mapLeft { DomainError(it) }
But I think it’s not as beautiful as it can be…Sagar Suri
09/07/2020, 2:32 AMgenovich
09/07/2020, 10:18 AMEither
to json using Jackson, and I faced with issue: when I try to serialize Either
instance - everything is ok, but when I try to serialize some wrapper-class with Either
I’ve got an exception. For Gson behavior changes: it’s returning null.
println(toJson("x".right()))
// { "value" : "x" }
data class Wrapper(val value: Either<Throwable, String>)
println(toJson(Wrapper("x".right())))
// java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Index: 0 (through reference chain: Test$test$Wrapper["value"])
// null (for Gson)
I’m using custom serializer which converts Either.Right
to { "value" : … }
and Either.Left
to { "error": … }
, but when I’m removing it, behavior doesn’t change.Jörg Winter
09/07/2020, 3:29 PMIOs parTraverse
to fx-coroutines parTraverse
seem to gives me about 20 to 26 percent performance gain !
...to authors & experienced users of fx-coroutines: is that your observation too ?
(and for sure it is much more concise and elegant 🙂 )CLOVIS
09/07/2020, 9:35 PMTristan Blakers
09/08/2020, 1:10 AMsuspend fun <A, B, C> EitherOf<A, B>.flatMapSuspend(f: suspend (B) -> Either<A, C>): Either<A, C> =
fix().let {
when (it) {
is Either.Right -> f(it.b)
is Either.Left -> it
}
}
Tristan Blakers
09/08/2020, 1:10 AMsuspend fun <A, B, C> EitherOf<A, B>.flatMapSuspend(f: suspend (B) -> Either<A, C>): Either<A, C> =
fix().let {
when (it) {
is Either.Right -> f(it.b)
is Either.Left -> it
}
}
Youssef Shoaib [MOD]
09/08/2020, 2:32 PMthan_
09/08/2020, 3:35 PMeither{
someEither.bind().let{ someSuspendingStuff(it) }.bind()
}
this works 🙂Tristan Blakers
09/11/2020, 9:11 PM