Open Sintrastes opened 3 years ago
Thank you :)
Yes there are. I had even started implementing something like this. I wanted to map Aff in ps to coroutines in kotlin, but I got stuck at implementing a runtime for Aff.
My attempts at implementing Aff using coroutines can be found here: https://github.com/csicar/pskt-foreigns/tree/coroutines
ATM I'm not looking at trying again, but I'd be happy to get PRs for it ;)
@csicar Am I understanding correctly by a runtime for Aff essentially you're just interpreting all of the "base" functions in Aff
as suspend fun
s in Kotlin (or, actually I see in your code base it looks like you're using (A) -> Deffered<B>
-- but as I understand it, that's an isomorphic representation with the semantics of Kotlin).
If so, what are the current open problems with this approach? No guarantees in terms of when I'd actually have the time to dig into it -- but I'd be happy to contribute time permitting.
As a somewhat related question: Have you thought at all about supporting interop with @Composable
functions? I'm not sure exactly what the best approach there would be, or how that would look, but it'd be killer to use something like Halogen for organizing components with a compose backend to handle the actual tree diffs/rendering.
Sorry for the late response.
Am I understanding correctly by a runtime for Aff essentially you're just interpreting all of the "base" functions in Aff as suspend funs in Kotlin
Yes, that's right.
If so, what are the current open problems with this approach?
I'm not sure there are any. The problem is just, that a understand neither Aff
nor Coroutines
well enough to be sure that their behaviour matches. I never really worked with Aff
s Fiber
, so I didn't fully understand the semantics, which made it hard to implement the ffi.
If you'd like to have a try at implementing Aff
for pskt, I'd suggest looking at the https://github.com/csicar/pskt-foreigns/edit/coroutines/Foreign.Effect.Aff.kt file and try to fill in the TODO()
s. If you need help setting up a dev environment for working on that stuff, I'd be happy to help.
actually I see in your code base it looks like you're using
(A) -> Deffered<B>
Yes, I think suspend fun
and (A) -> Deferred<B>
should be equivalent in Kotlin. I used the second form, because that didn't require modifying the pskt compiler ;)
Have you thought at all about supporting interop with @Composable functions?
Yes, very much. AFAIK Jetpack Compose unfortunately does not use a vdom, but instead does compile-time analysis of your code to insert update to the ui calls at the appropriate places. That could prove challenging to implement in the FFI.
There is also an early attempt at implementing a vdom for normal android widgets, which can be found here: https://github.com/csicar/purescript-android-todomvc/blob/master/ps/src/Main.purs
Hello! First off, I'd just like to say: Thank you for this great project. As someone who loves Kotlin, but also occasionally wants to do some pure-script style things on Android, this is great!
I was just wondering: Are there any plans to support a representation of Kotlin-specific types like
suspend
functions on the pure-script side? I suppose this could be something like aAsyncEff
orSuspendEff
function on the purescript side that gets converted into a suspend fun in the backend.