Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Scala Native #1549

Open
djneades opened this issue Mar 8, 2017 · 36 comments

Comments

@djneades
Copy link

@djneades djneades commented Mar 8, 2017

It is early days for Scala Native (https://github.com/scala-native/scala-native), but support would be be very helpful.

@jcranky

This comment has been minimized.

Copy link
Contributor

@jcranky jcranky commented Mar 8, 2017

Perhaps it is a naive question, but would supporting scala native means in practice?

@djneades

This comment has been minimized.

Copy link
Author

@djneades djneades commented Mar 8, 2017

That’s a good question. I have only just begun to look at Scala Native myself, but immediately ran into problems because none of my project’s dependencies had Scala Native support (hence this issue). I see that the scalaz folks have recently started to support Scala Native, so their work may give a few useful pointers as to what could be required: https://github.com/scalaz/scalaz/wiki/7.3.0-M10

I suspect that some of the Cats dependencies (e.g. Simulacrum) will need themselves to acquire Scala Native support before Cats itself can do so.

@mscharley

This comment has been minimized.

Copy link

@mscharley mscharley commented Mar 22, 2017

  1. So, compiler plugins should continue to work and not need any changes. (I believe)
  2. Any JVM dependencies however will need to be ported across.
  3. This project would need to be cross-compiled.

For a taste, here's a PR for a simple library I manage: mscharley/scala-xoroshiro128#4

@aoiroaoino

This comment has been minimized.

Copy link
Contributor

@aoiroaoino aoiroaoino commented Apr 3, 2017

@mkotsbak

This comment has been minimized.

Copy link

@mkotsbak mkotsbak commented May 1, 2017

@mscharley 2. JVM dependencies should not be a problem as Cats is already supporting Scala.Js which also does not support any JVM dependencies.

@4lex1v

This comment has been minimized.

Copy link

@4lex1v 4lex1v commented Jun 30, 2017

I'd to try Cats with some experimental Scala Native code, any chance that this issue will get some attention? How hard to add support for Scala Native?

@johnynek

This comment has been minimized.

Copy link
Collaborator

@johnynek johnynek commented Jun 30, 2017

I don't know of anyone working on it. Someone interested should just try. It is probably just some sbt surgery to get it to work. I very much doubt dependencies or jdk usage will be a barrier.

@ChetanBhasin

This comment has been minimized.

Copy link

@ChetanBhasin ChetanBhasin commented Sep 13, 2017

I would love to try out my hand at this, but I think a bigger bottleneck is Simulacrum at this point.

According to Scaladex, Simulacrum doesn't yet support native, but I'm not sure how substantial changes would be required there to support native.

@denisrosset

This comment has been minimized.

Copy link
Contributor

@denisrosset denisrosset commented Oct 10, 2017

Adding support for scala native to simulacrum was not a big deal; see typelevel/simulacrum#92

However, it looks like scalacheck/scalatest will not be supported any time soon!

@schrepfler

This comment has been minimized.

Copy link

@schrepfler schrepfler commented Nov 7, 2017

Just to highlight, if we get cats-kernel for SN, we can probably pull spire fore SN which would be really interesting to benchmark.

@cb372

This comment has been minimized.

Copy link
Contributor

@cb372 cb372 commented Dec 7, 2017

I managed to cross-build cats-kernel for scala-native. Here's the commit with my changes. Happy to submit a PR if it's deemed useful.

I made a toy project that uses cats-kernel and actually works in scala-native, which is pretty cool!

Getting any other modules to cross-build is a lot more complicated, as others have discovered in the comments above.

Here is the list of things that I think are still blocking cats-core from being cross-built:

  • simulacrum - PR in progress
  • machinist - PR raised but ignored - is this project dead? Hasn't seen any maintenance for months. PR is now slightly out of date.
  • scalatest - PR has been going on for months but is still being actively worked on

And these are blocking the various testing/laws modules from being cross-built:

  • scalacheck - PR in progress
  • discipline - no issue/PR
  • catalysts - issue
@kubukoz

This comment has been minimized.

Copy link
Contributor

@kubukoz kubukoz commented Jul 3, 2018

Update for Scalacheck - typelevel/scalacheck#368 is merged, but the artifacts seem not to be published yet. Progress in typelevel/scalacheck#396

@kubukoz

This comment has been minimized.

Copy link
Contributor

@kubukoz kubukoz commented Jul 7, 2018

Aaand I added an issue for Discipline: typelevel/discipline#57

@sorenbug

This comment has been minimized.

Copy link

@sorenbug sorenbug commented Sep 12, 2018

Status update:

Here is the list of things that I think are still blocking cats-core from being cross-built:

  • simulacrum - PR in progress
  • machinist - PR raised but ignored - is this project dead? Hasn't seen any maintenance for months. PR is now slightly out of date.
  • scalatest - PR has been going on for months but is still being actively worked on

I checked all of these PRs and either them or their replacements have been merged. 🎉

And these are blocking the various testing/laws modules from being cross-built:

  • scalacheck - PR in progress
  • discipline - no issue/PR
  • catalysts - issue

Scalacheck artifact publishing seems to be paused/abandoned? Last comment is past one month. rickynils/scalacheck#396

Discipline has a new issue:

Aaand I added an issue for Discipline: typelevel/discipline#57

The catalysts issue typelevel/catalysts#11 hasn't had any activity. The last commit to master is from 2 months ago.

Update:

For catalysts, I am helping with maintenance, but could use some help on adding native support (once unblocked with scalacheck)

Summary:

  • Simulacrum
  • Machinist
  • Scalatest
  • Scalacheck (Dead?)
  • Discipline (Blocked by Scalacheck)
  • Catalysts (Blocked by Scalacheck)
@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Sep 12, 2018

For catalysts, I am helping with maintenance, but could use some help on adding native support (once unblocked with scalacheck)

@Alistair-Johnson

This comment has been minimized.

Copy link
Contributor

@Alistair-Johnson Alistair-Johnson commented Nov 10, 2018

re catalysts... see typelevel/catalysts#11

@Alistair-Johnson

This comment has been minimized.

Copy link
Contributor

@Alistair-Johnson Alistair-Johnson commented Nov 10, 2018

OTOH... I wondering if it's useful to add scala-native support wherever we can in the build, even if that means code cannot be tested. And what about publishing untested code?

Just some thoughts...

@schrepfler

This comment has been minimized.

Copy link

@schrepfler schrepfler commented Nov 24, 2018

This would be great to happen.

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Feb 27, 2019

Seeing no interest from Scalacheck maintainer on Scala native artifact publishing, I published it under my groupid.
You can use it: "com.github.lolgab" %%% "scalacheck" % "0.4.1".

@schrepfler

This comment has been minimized.

Copy link

@schrepfler schrepfler commented Feb 27, 2019

So I guess now all we need is Discipline and Catalyst? Will anyone reach out to the project leads?

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Feb 28, 2019

I'm working on porting Catalysts.

@denisrosset

This comment has been minimized.

Copy link
Contributor

@denisrosset denisrosset commented Mar 1, 2019

Ohoh, it seems that cats-kernel already works. If algebra is ported (I don't see any obstacle), we'll see which parts of Spire cooperate well!

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Mar 1, 2019

I tried to port Catalyst. It uses a custom sbt plugin with all typelevel libraries versions.. And not all of them crosscompile. The plugin doesn't allow to use different groupids for the same artifact ( org.scalacheck for jvm and js and com.github.lolgab for native).
There is another problem, scalatest 3.1.x is not compatible with scalacheck, but uses its Generators. I ported upickle's scalacheck tests to scalatest but with cats:

  • there are a lot more tests
  • I don't think you want to use SNAP version of the testing library.
@schrepfler

This comment has been minimized.

Copy link

@schrepfler schrepfler commented Mar 1, 2019

We need some help from @kailuowang

@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Mar 1, 2019

@lolgab, thanks so much for spearheading this.
sbt-catalyst shouldn't be a problem. It is designed as a library rather than framework, so if there is any usage of it that doesn't support your use case you can just replace it with your own sbt settings. For example, if you want different groupids, you can just delete the specific sbt-catalyst usage and write that dependency setting the common way.

I think for the scala native build, we might be okay to depend on SNAP.

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Mar 1, 2019

Rewriting tests for scalatest 3.1.x and use only on scalatest build can be useful in near future when scalatest 3.1.0 goes stable. You only need to move test folder from native to shared to update cats tests :)

@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Mar 1, 2019

Does scalatest 3.1 have cogen?

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Mar 2, 2019

It seems to not have them. Then I have to find a workaround to integrate Scalacheck with it. I give a try and let you know.

@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Mar 4, 2019

Thanks!

@Baccata

This comment has been minimized.

Copy link

@Baccata Baccata commented Mar 21, 2019

👋 hi there, I'm a heavy cats user writing a library and I'm pondering whether to depend on cats in the core, as cross-compiling to native would be fairly desirable.

Anything I could help with on this ?

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Apr 16, 2019

Discipline depends on specs2 but I think the specs2 side is irrelevant for cats (it has 2 optional dependencies, specs2 or scalatest. How can we work around it? Port specs2 is hard..

@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Apr 16, 2019

@lolgab one way I can think of is to break out discipline's specs2 dependent code into a new module and thus rid of cats dependency on specs2 - maybe in that light, we should do the same with scalatest dependent code as well.
IIRC, it shouldn't take too much time. I can support you on the discipline side.

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Jul 27, 2019

@kailuowang I made a PR to discipline to remove specs2 dependency from core:
typelevel/discipline#105
There were only a Test I rewrote in scalacheck (because it is already a dependency of discipline).
I changed a little the .travis.yml to test both Scala Native 0.3.9 and 0.4.0-M2.
Hope you'll publish the artifact for the two after merging :)

@lolgab

This comment has been minimized.

Copy link

@lolgab lolgab commented Jul 27, 2019

In the meantime I published some artifacts for Scala Native 0.3 and 0.4.0-M2 under my organization:

"com.github.lolgab" %%% "cats-core" % "2.0.0-M4"

All cats library is supported..

@kailuowang

This comment has been minimized.

Copy link
Member

@kailuowang kailuowang commented Jul 27, 2019

thanks @lolgab , let's see if we can get them to add a new active maintainer.

@sorenbug

This comment has been minimized.

Copy link

@sorenbug sorenbug commented Sep 15, 2019

Artifacts for Scalacheck/Native have been published! typelevel/scalacheck#396 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.