Matt Thiffault
10/02/2019, 10:15 PMlaimiux
10/03/2019, 5:56 PMTolegen Izbassar
10/06/2019, 12:15 PMjackson
de-serializer for the Option
type? https://stackoverflow.com/questions/58257121/how-to-write-custom-jackson-deserializer-in-kotlin-for-arrows-optionkvothe
10/07/2019, 3:26 PMMatt Thiffault
10/07/2019, 8:31 PMMatt Thiffault
10/07/2019, 8:37 PM!effect { ioRecurseNTimes(n - 1) }.bind()
, I don't get a stack overflow but everything seems to slow down and my CPU starts to work really hard after about 400k recursions.stojan
10/07/2019, 9:00 PMRyan Benasutti
10/08/2019, 12:43 AMJoram Visser
10/08/2019, 7:37 AMMatt Thiffault
10/08/2019, 7:44 AMpakoito
10/09/2019, 11:02 AMBob Glamm
10/09/2019, 3:32 PMpakoito
10/09/2019, 5:18 PMpakoito
10/09/2019, 5:41 PMMatt Thiffault
10/10/2019, 6:47 PMval deferredReply = async { startListening(replyChannel) }
sendChannel.send(message)
val reply = defferedReply.await()
What would be the idomatic way to do this with Arrow? Is it asyncF I'm looking for?pakoito
10/11/2019, 10:48 AM@extension interface Bla<T> {
fun showLogin(par: T): ReaderT<ForIO, Context, Unit> = ... // some ugly ReaderT blob
}
Stian N
10/11/2019, 10:51 AMalilosoft
10/12/2019, 12:08 PMGood day. I'm new to functional programming and the arrow library and was wondering if anybody can help me.
I was wondering how one handles resources like database pools or connections and how you pass them to a function. For instance: Let say I have an authenticate method:
fun authenticate(username: String, password: String): Either<Error, Token> {
// validation etc ..
val user = getUserByUsername(username)
}
fun getUserByUsername(username: String): Option<User> {
// JDBC Query for user
val rs = con.prepareStatement("SELECT * FROM user .....")
....
val user = mapRowToUser(rs) // etc
return Option.fromNullable(user)
}
My question is do I pass in the connection of database pool as a parameter like so:
fun authenticate(con: Connection, username: String, password: String) ....
fun getUserByUsername(con: Connection, username: String): Option<User> ...
What is the best practice when it comes to functional programming?
Also from what I have read and if my understanding is correct, this is impure and normally IO would be used?
fun getUserByUsername(username: String): IO<Option<User>>
Is this correct? Any help appreciatedPS: I think it could be better if a link to this channel is added to Arrow-kt.io web site home page.
jimn
10/13/2019, 10:24 AMpakoito
10/13/2019, 11:33 AMgirafferson
10/13/2019, 5:32 PMMatt Thiffault
10/13/2019, 5:34 PMsimon.vergauwen
10/14/2019, 11:52 AMIO
can run in a cancellable way with a cancelable reference typealias Disposeable = () -> Unit
. Whenever the coroutine gets cancelled you can also cancel the underlying IO
using that reference.
fun <A> IOOf<A>.suspendCancellable() : Either<Throwable, A> =
suspendCancellableCoroutine { continuation ->
val disposable = fix().unsafeRunSyncCancellable { continuation.resume(it) }
continuation.invokeOnCancellation { disposable.invoke() }
}
simon.vergauwen
10/14/2019, 11:57 AMarrow-android
we’d love to help people get started with any help they need 🙂raulraja
10/14/2019, 9:36 PMpakoito
10/15/2019, 2:10 PMpakoito
10/16/2019, 10:22 AMBob Glamm
10/16/2019, 2:10 PMEither<Throwable, Unit>
pakoito
10/16/2019, 2:15 PM.handleErrorWith { IO { log(it) } }
if it's an effectImran/Malic
10/17/2019, 2:31 PM