tmg
08/13/2019, 2:07 PMtmg
08/13/2019, 3:54 PMstojan
08/13/2019, 4:52 PMDerek Berner
08/13/2019, 6:41 PMRafal Piotrowski
08/14/2019, 9:49 AMBob Glamm
08/15/2019, 7:55 PMRoute.get(path: String, body: suspend PipelineContext<Unit, ApplicationCall>.(Unit) -> Unit): Route
from something more like Route.get(path: String, body: Async<F>.(ApplicationCall) -> Kind<F, Unit>): Route
? I keep running into issues where trying to just transform the second argument from Async
to PipelineContext
cannot resolve .fix().suspended()
to end up with suspend () -> Unit
Rafal Piotrowski
08/19/2019, 12:43 PMDeferred
class from kotlinx.coroutines
, sample code is below. As you can see I have DemoService
and DemoRouting
which have no suspend method and are parametrized with type F
. I define F
as IO
when the server is created (so on the end of the world ;)). I could use different monad (e.g. Try
) after implementing the Deferrable
interface. Please let me know what you think about this approach. @Bob Glamm, this is a little bit different than using Async
directly as we spoken recently, there is a separate typeclass to transform value into deffered value.miqbaldc
08/21/2019, 7:28 AMarrow-java
?raulraja
08/21/2019, 10:01 AMLeoColman
08/21/2019, 8:21 PMtry {
foo()
} catch(FooException) {
} catch(BarException) { }
raulraja
08/21/2019, 10:29 PMSequenceK
raulraja
08/24/2019, 12:17 PMBrandon Ward
08/26/2019, 10:08 PMIO
? The docs are unclear and refer to dependencies that don't exist for this version, or don't exist at all.PhBastiani
08/27/2019, 12:09 PMfx
syntax for comprehensions... If i understand, the new impl uses coroutines under the cover !
I replaced the calls of bindind()
by fx.monad
Now, I have something like that :
fx.monad {
val vMaybe:Option<T> = ...
vMaybe.map { mymonadfunction(...).bind() }
...
Here, the call of bind()
gives me an error 'Suspension functions can be called only within coroutine body'... What is the new syntax for this kind of binding ? Thx in advance....Bob Glamm
08/27/2019, 12:59 PMfx.monad {
val v: T = !foo(x) // fun foo(x: Any): Option<T>; v is bound to T since ! is an alias of bind()
!mymonadfunction(v) // fun mymonadfunction(t: T): Option<R>; value of fx.monad {} block will be Some(R) or None
}
Rafal Piotrowski
08/28/2019, 9:02 AMRobert Menke
08/28/2019, 3:34 PMSergey Akhapkin
08/28/2019, 8:26 PMimport arrow.core.*
Try.invoke { "1" }.flatMap<Int> { throw IllegalArgumentException() }
java.lang.IllegalArgumentException
scala.util.Success<String>("a").flatMap<Int> { throw IllegalArgumentException() }
res28: scala.util.Try<kotlin.Int!>! = Failure(java.lang.IllegalArgumentException)
or in native Scala REPL:
System.out.println(scala.util.Try("x").flatMap{ s => throw new java.lang.IllegalArgumentException(s) })
> Failure(java.lang.IllegalArgumentException: x)
Bob Glamm
08/29/2019, 1:06 PMPhBastiani
08/29/2019, 3:48 PMpakoito
08/30/2019, 10:43 AM!put("A", 1)
is called. We know it never reaches the interpreter.Ryan Benasutti
08/30/2019, 10:12 PMpakoito
08/31/2019, 8:48 PMraulraja
08/31/2019, 10:50 PMsuspend fun String.parseDate(): Either<DateParseError, Date> =
Either.catch({ e -> DateParseError(e) }) {
dateFromString(this)
}
raulraja
09/01/2019, 12:06 AMBob Glamm
09/01/2019, 2:40 AMFred Friis
09/02/2019, 3:39 AMOption.else
vs Option.getOrElse
and
Either.filterOrElse
vs Either.filterOrOther
AdrianRaFo
09/02/2019, 8:10 AMOption.getOrElse
returns the value inside if the Option
is a Some
or return the provided param if it's a None
- Option.orElse
returns the same Option
if it's not None
, otherwise returns the provided Option
The difference here is that getOrElse
will return the value outside the Option
context but the orElse
keep that contextsimon.vergauwen
09/03/2019, 1:47 PMApplicative
enables combining elements using map
for any number of arguments 🙂raulraja
09/03/2019, 2:58 PMdata class Data(val a: String, val b: String)
data class Error(val msg: String)
val data : Either<Error, Data> = Either.applicative<Error>().map("".right(), Error("oops").left(), ::Data).fix()
//Left(Error("oops"))
raulraja
09/03/2019, 2:58 PMdata class Data(val a: String, val b: String)
data class Error(val msg: String)
val data : Either<Error, Data> = Either.applicative<Error>().map("".right(), Error("oops").left(), ::Data).fix()
//Left(Error("oops"))
tupled
map
is only useful if you plan to transform them in the map function otherwise tupled is all you need