Bob Glamm
02/20/2020, 4:51 PMfun <F> F.updateTimezone(ctx: DocumentContext): Kind<F, DocumentContext> where F: MonadThrow<F> { ... }
(with arrow 0.10.x), but IIRC I am waiting for Arrow 1.0 to have the equivalent of Scala's (implicit MT: MonadThrow[F])
, right?simon.vergauwen
02/20/2020, 4:56 PMMonadThrow<F>
instead which allows me to use it within fx.monadThrow { }
or use it on the receiver.
By doing so you can also call these functions from each-other without having to pass the argument.
fun <F> Async<F>.test(): Kind<F, Unit> = unit()
fun <F> Async<F>.helloWorld(): Kind<F, Unit> = effect { println("Hello World") }
fun <F> Async<F>.asyncProgram() = test().flatMap { helloWorld() }
simon.vergauwen
02/20/2020, 4:56 PMBob Glamm
02/20/2020, 4:57 PMhelloWorld
is part of Async<F>
, which just strikes me as weirdBob Glamm
02/20/2020, 4:57 PMclass
, which is finesimon.vergauwen
02/20/2020, 4:59 PMhelloWorld
is part of `Async<F>`“. I’ve always thought about it as “the first param is implicitly passed, which allows calling it as syntax for the first argument.
So where you typically do ``(implicit MT: MonadThrow[F])` ` as last argument in Scala, I do the same but as a receiver in Kotlin.simon.vergauwen
02/20/2020, 5:00 PMAsync<F>
, it has nothing to do for the type or class which just defines behavior for F
.Bob Glamm
02/20/2020, 6:00 PMBob Glamm
02/20/2020, 6:01 PMimplicit
function parameter easier to reason about, I guess: "This function requires some evidence that this typeclass instance exists for the given effect"Bob Glamm
02/20/2020, 6:02 PMraulraja
02/20/2020, 8:33 PMraulraja
02/20/2020, 8:35 PM