arrow-kt / arrow

Λrrow - Functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
6.18k stars 452 forks source link

Kotlin JS / multi-platform support #1007

Closed wadejensen closed 3 years ago

wadejensen commented 6 years ago

I went to use Arrow for a frontend application transpiled from Kotlin to JavaScript and realised that it Arrow doesn't support the JS platform due to explicit Java dependencies. It would be awesome to see Arrow migrate to being a multiplatform library.

raulraja commented 6 years ago

@wadejensen I think this is everyone's desire as well but nobody currently pushing the lib has that use case. If you want to give it a shot the first thing we have to do is compile a shopping list of what needs to change currently in the code base to support Kotlin JS/Native and we can take it from there recommending approaches to tackle each one of the parts.

wadejensen commented 6 years ago

Thanks for the response @raulraja. My use case is very casual at the moment, so I don't have bandwidth to dedicate to this, but if that changes I will give it a red hot go.

pakoito commented 6 years ago

@AregevDev took a look for the Native port, and we're currently blocked on kapt and KindedJ. There's also a concurrent map in some memoization function, but that's fixable.

raulraja commented 6 years ago

@pakoito so no kapt on js and native?

pakoito commented 6 years ago

No, and no plans for it either.

AregevDev commented 6 years ago

Maybe try to generate the code and then call the compiler to include the generated classes?

AregevDev commented 6 years ago

They are only generating a class and two typealiass...

janvladimirmostert commented 5 years ago

what is kapt used for, only for the @optic annotations ?

pakoito commented 5 years ago

@higherkind is the blocker for arrow-core, @extends for arrow-typeclasses

JorgeCastilloPrz commented 5 years ago

I also assume kapt (specifically annotation processors) will not be a thing for JavaScript either. We'd probably need to look for alternatives on code derivation for both platforms that can have a common API but implemented differently.

1Jajen1 commented 5 years ago

How do projects like kotlinx.serialization etc work? Are they providing their own compiler plugin? Maybe that is a way to go, may be a lot of work tho.

viluon commented 5 years ago

Regarding compiler plugins, this is a valuable resource.

MattX commented 4 years ago

(I don't know much about JVM annotation processors, so maybe this is very dumb)

My understanding is that Kapt, like other annotation processors, will generate extra .kt files, which are then included in the regular compilation process. Would it be possible to run Kapt in a JVM environment to generate these files, and then compile everything with the Kotlin/JS compiler? I'm curious to know why not if not.

mkotsbak commented 4 years ago

Maybe https://github.com/Foso/MpApt could be used instead of kapt? It supports multiplatform.

kierans commented 3 years ago

My use case is that I'm writing a library that I want to be able to use on iOS as well as JVM targets (including Android). It would be super awesome if Arrow could do this.

nomisRev commented 3 years ago

Hey @kierans, (and everyone following this thread) These efforts are currently in progress. You can follow the progress in the PRs.

Here is a link to the PR working on JS support (almost finished for Arrow Core), Native is up next :) https://github.com/arrow-kt/arrow/pull/2409 Native for Arrow Fx Coroutines might be a little delayed compared to other libraries, since the underlying library KotlinX Coroutines support for native is still experimental and not officially released under the stable releases AFAIK.

As soon as this is merged you can try it on th SNAPSHOT release, the first MILESTONE for Arrow 1.0.0 is expected this summer.

kierans commented 3 years ago

@raulraja Can you say why you closed this please? It seems a bit arbitrary.

viluon commented 3 years ago

I see that #2409 got merged, but I'd say proper support also requires documentation on setting up a multiplatform project with Arrow (and perhaps which Arrow libraries work with JS and which ones don't).

raulraja commented 3 years ago

@kierans @viluon Arrow is now MPP in main, and all tests are passing. The site also is being published next week with instructions to include Arrow MPP in any project as soon as we can add the native tests, which we are waiting for support for Kotest. I closed this because the work is done but reopening now until it's all available to the public.

kierans commented 3 years ago

Thanks for the update @raulraja.

nomisRev commented 3 years ago

For those wanting to try Arrow on JS. https://github.com/arrow-kt/Arrow-JS-Template

nomisRev commented 3 years ago

This ticket can finally be closed 🥳 Arrow 1.0 comes with JS support! If you have any feedback be sure to create an issue here, or chat in #arrow on Kotlin Slack.

kierans commented 3 years ago

@nomisRev Given this ticket was also about "multi platform support", does this also mean that Arrow 1.0 can be used in native code eg: iOS?

pakoito commented 3 years ago

@nomisRev Given this ticket was also about "multi platform support", does this also mean that Arrow 1.0 can be used in native code eg: iOS?

Yes!!

mysticfall commented 2 years ago

I believe we still lack compiler support for Optics on non-JVM platforms? If so, is there an ongoing effort or existing issue about it?

If there's none, I'd like to open a feature request so that I could keep track of updates.

nomisRev commented 2 years ago

Hey @mysticfall,

This is already in progress on the Arrow Meta repo, and we're currently testing it before releasing it. There is a ticket here, https://github.com/arrow-kt/arrow-meta/issues/771.

mysticfall commented 2 years ago

@nomisRev Thanks much for the info! I'll subscribe to the issue then. Can't wait to test it myself :)