These are chat archives for ReactiveX/RxJava

6th
Jun 2016
Paco
@pakoito
Jun 06 2016 18:48
stupid question time
how does RxJava Observable monad relate to the Free monad?
I'm reading about for comprehensions and they look a lot like our observable chains
Artem Zinnatullin :slowpoke:
@artem-zinnatullin
Jun 06 2016 21:29
@pakoito yo there man :) yeah, it's quite similar, especially because errors do not leave chain (mostly), not a functional expert though
Paco
@pakoito
Jun 06 2016 21:55
We need an expert!
where's the church of the monad when you need it?
Artem Zinnatullin :slowpoke:
@artem-zinnatullin
Jun 06 2016 21:56
well, they don't follow IO so they can't connect to Internet lol
lemme invite one guy
cc @karlicoss
Dima Gerasimov
@karlicoss
Jun 06 2016 22:35
sup, I actually have no idea lol
I mean as far as I remember free monads are some kind of generic monads you can build from an arbitrary functor, but never really got to use it
@pakoito why did you think of free monad in the first place by the way?
Paco
@pakoito
Jun 06 2016 22:38
I'm coming from RxJava into Free Monads
right now I'm on the early learning phase
aka I know how to form them, but still trying to figure out their usage
and so far they look a lot like our Rx chains
Dima Gerasimov
@karlicoss
Jun 06 2016 22:39
ah got it
wait, by chain you mean just operations on observables?
Paco
@pakoito
Jun 06 2016 22:41
yes, all the way down before the subscription
the "bendy pipe"
Dima Gerasimov
@karlicoss
Jun 06 2016 22:42
well, I can see why Observable/Single is a monad, just don't know why would it be free
Paco
@pakoito
Jun 06 2016 22:43
it isn't necessarily free
but that it seems to be solving the same problem
free monad stems from the need to have a way of expressing stateful operations as stateless chains, so you get those sweet FP benefits
so they use coyoneda to lift anything into a functor, and then that functor onto free, so now every anything ever is now a monad
map, flatMap, etc
which is kind of what Observable does if you structure your program the right way
maybe a bit more code around the edges wrapping your UI layer, but same stuff
Dima Gerasimov
@karlicoss
Jun 06 2016 22:48
heh now I am curious too
damn, I constantly forget what Yoneda (hence, co-Yoneda) lemma is about, I re-read it occasionally, assure that I understand it, and then forget