Marcin Gryszko
06/25/2019, 5:33 AMFx
interfaces: one declared in arrow.effects.typeclasses.suspended.concurrent
package (with IOFx
implementation, another one in arrow.effects.typeclasses.suspended.monad
(for the rest of monad implementations). Is there a reason that they are separated?Bob Glamm
06/26/2019, 8:26 PM<F>
in something like the following:
interface S3Ops<F>: MonadDefer<F> {
val s3: AmazonS3
fun getS3Info(bucket: String, key: String): Kind<F, S3Object> {
val waiterRequest = GetObjectMetadataRequest(bucket, key)
return catch { s3.waiters().objectExists().run(WaiterParameters(waiterRequest)) }
.flatMap {
val objectRequest = GetObjectRequest(bucket, key)
catch { s3.getObject(objectRequest) }
}.flatMap {
if (it == null) {
raiseError(RuntimeException("No object retrieved from S3"))
} else {
just(it)
}
}
}
Imran/Malic
06/26/2019, 9:29 PMBob Glamm
06/28/2019, 1:56 PMDerek Berner
06/28/2019, 2:37 PMFree
monad? Or should we be preferring IO
for that?Derek Berner
06/28/2019, 2:47 PMFree
monad in Elm one time because their `Cmd`s were frustratingly not monadic...)AdrianRaFo
07/01/2019, 9:23 PMflatTap
?pakoito
07/02/2019, 9:19 PMHieiJ
07/04/2019, 8:23 PMHieiJ
07/05/2019, 11:24 AMTim Fennis
07/09/2019, 8:07 AMnicopasso
07/09/2019, 9:06 AMbindingCatch
to compose a sequence of actions (API call, db call etc). What’s the best way to test it and to assure the actions are executed?than_
07/09/2019, 10:25 AMthan_
07/10/2019, 10:20 AMkioba
07/15/2019, 3:41 PMJorge Castillo
07/15/2019, 3:48 PMsimon.vergauwen
07/15/2019, 4:08 PMdata class UseCaseContext(val repo: Repo, val db: Db)
, now your use cases logic is coupled to UseCaseContext
and you can deal with your dependencies further as you normally would. Interface segregation etcBob Glamm
07/16/2019, 3:23 AMBob Glamm
07/16/2019, 3:32 AMEither l r :: * -> * -> *
is implemented via Kind<F, A>
in Arrowsimon.vergauwen
07/17/2019, 2:00 PMFlux<A>
to suspend () -> List<A>
or Mono<A>
to suspend () -> A?
carbaj0
07/17/2019, 2:20 PMobject : FxSyntax<ForIO> by IO.fx() { }
simon.vergauwen
07/17/2019, 2:38 PMRyan Benasutti
07/17/2019, 2:39 PMSetK.applicative()
similar to ListK.applicative()
?sean
07/17/2019, 9:04 PMfx
, Either
and coroutines
? I've been going over the documents and feel like I'm just missing something. I see effect but it looks like it's under the IO data type.HieiJ
07/18/2019, 6:39 AMdr.dreigh
07/18/2019, 10:53 AMBob Glamm
07/18/2019, 12:30 PMktor
and Arrow:
val q: (ApplicationCall) -> Kind<ForIO, Unit> = { c -> IO.fx().fx { c.respondText("Foo", ContentType.Text.Html) } }
c.respondText
is a suspending function not in IO
and @RestrictsSuspension
on IO
prevents the composition from occurring that wayImran/Malic
07/18/2019, 4:23 PMWhy can I get from every Comonad an Monad, but not the other way around?
Derek Berner
07/19/2019, 3:45 PMsimon.vergauwen
07/19/2019, 4:01 PMleftFlatMap
but that currently doesn’t exist in Arrow.simon.vergauwen
07/19/2019, 4:01 PMleftFlatMap
but that currently doesn’t exist in Arrow.pakoito
07/19/2019, 5:25 PMRobert Menke
07/19/2019, 6:00 PMflatMapLeft
I did create a branch with the functionality + test. I get an error pushing my branch up to origin because of permissions. No big deal if you’d prefer not to add extra code to maintain @simon.vergauwen @pakoito. Up to you guys.pakoito
07/19/2019, 6:00 PMsimon.vergauwen
07/19/2019, 6:01 PMhandleErrorWith
L
but rather leaves it generic.Robert Menke
07/19/2019, 6:04 PMhandleErrorWith
does work perfectly for my use case so I can stick with that. Thanks for pointing me in the right direction!pakoito
07/19/2019, 6:04 PMflatMapLeft
is a specialized handleErrorWith
simon.vergauwen
07/19/2019, 6:05 PMpakoito
07/19/2019, 6:05 PMsimon.vergauwen
07/19/2019, 6:06 PMfun <A, B, C> Either<A, B>.leftFlatmap(f: (A) -> Either<C, B>): Either<C, B> = when(this) {
is Either.Left -> f(this.a)
is Either.Right -> this
}
fun <A, B> Either<A, B>.handleErrorWith(f: (A) -> Either<A, B>): Either<A, B> = leftFlatMap(f)
leftFlatMap
to come back when we complete the bifunctor hiearchy.IO<E, A>
over handleErrorWith
E
to Nothing
, well I guess you could name it handleErrorWith
in a bifunctor hierarchy but then it would be an alias. Here it’s not.Robert Menke
07/19/2019, 6:18 PMhandleErrorWith
is not an inline
function so it actually doesn’t work for my use case because I need to call suspend
functions inside. I can get by with fold
for now, just voicing my experience.simon.vergauwen
07/19/2019, 6:20 PMIO
comes in, Either
cannot deal with the powers of suspend
. It cannot control the async jumps, exception being thrown etc.Robert Menke
07/19/2019, 6:21 PMflatMap
or fold
but not something like handleErrorWith
?simon.vergauwen
07/19/2019, 6:21 PMIO
you'd do io.handleErrorWith { e -> IO.effect { suspendFunction() } }
Robert Menke
07/19/2019, 6:28 PM