Worked through <https://www.pacoworks.com/2019/12/...
# arrow
m
Worked through https://www.pacoworks.com/2019/12/15/kotlin-coroutines-with-arrow-fx/ and tried to give it a shot on Android with Room (works great!) - however, I cannot get the
Promise
to mimic the view model lifecycle callback (as described at the end of the post):
Copy code
val endPromise: Promise<ForIO, Unit> = Promise.unsafeUncancelable(IO.async()).fix()
simply does not compile. Same for
Copy code
endPromise.complete(Unit).unsafeRunAsync { }
accordigly.
fix()
/
unsafeRunAsync
are simply not availble on the
Promise
instance. Any ideas?
j
complete
returns
Kind<ForIO, Unit>
afaik and I think you need
endPromise.complete(Unit).fix().unsafeRunAsync {}
fix()
in this case comes from
Kind<ForIO, Unit>.fix(): IO<Unit>
m
Thanks, Jannis; `fix`ing it does work.
j
Btw the fixing will sooner or later all be gone (with a compiler plugin). Right now it is a necessity to encode higher kinded types and can lead to quite a bit of confusion especially because ide's don't usually suggest it and can also take quite a while to show it as an option.
m
That's good to hear - seems like the PR to natively support typeclasses in Kotlin is stuck.
j
Well I think jb are pretty hesitant when it comes to adding features like this. Which I can understand, but it's a bit annoying for arrow. But that is also something coming as a compiler plugin. The current idea is to build a plattform for compiler plugins (arrow-meta) and build several quality of life plugins (that are hopefully not too invasive) on top of it to make arrow easier to use. This way one can also prototype some features that are added as KEEP's and test them in the wild. It's always sub-par to actual compiler support but it will be much better than nothing.
👍 2