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 ScalaJS #33

Closed
zainab-ali opened this issue Sep 19, 2017 · 10 comments
Closed

Add support for ScalaJS #33

zainab-ali opened this issue Sep 19, 2017 · 10 comments

Comments

@zainab-ali
Copy link
Contributor

This follows from a discussion with @cquiroz about Libra adoption.
Potentially many users need ScalaJS support.

Spire, shapeless and singleton-ops all support this, so it should be trivial to add.

@zainab-ali
Copy link
Contributor Author

ScalaJS would make the build matrix much larger, and consequently would cause an explosion in build times. I'd be happy to support this, but only if someone actually has a use for it.

If anyone does want to use libra with ScalaJS, please comment here.

@cquiroz
Copy link

cquiroz commented Dec 26, 2017

Build times tend to be larger for scala.js in any case and i guess it will double the matrix size right? i haven't followed this up as i wasn't able to update singleton-ops but now that you did I may give it a try

@zainab-ali
Copy link
Contributor Author

Yes, it would double the build times. Our build times are pretty small compared to most projects (5 - 6 minutes), so I'm happy to double them as long as someone has a use case. Adding ScalaJS should be fairly straightforward.

@cquiroz
Copy link

cquiroz commented Jan 1, 2018

The changes aren't that big but i'm having troubles running tests on the JS side. I'll let you know if I can make it work

@maekl
Copy link
Contributor

maekl commented Apr 16, 2020

I needed this and have a working implementation apart from a single failing test. Double.toString does not behave the same way in ScalaJS as on the jvm. It can be solved using platform-specific code (see for example how it was solved in squants)

The new directory layout would be:

.
├── core
        ├── js
        ├── jvm
        └── shared

If this sounds ok I'd be happy to wrap it up in a PR


I have submitted an idea (#108) which I think would provide another way to solve the platform differences (with the help of scala-java-locales)

@maekl
Copy link
Contributor

maekl commented Apr 22, 2020

Turns out platform specific code isn't required. Doubles just have to be formatted with something like "%.1f".format(d). Not easily done with the current code without something like #108 AFAICT

An alternative view is that nice & predictable formatting isn't (at least not yet) an important feature. After all, (0.1d + 0.2d).toString == "0.30000000000000004" is true. So, it might make sense to just update the failing test to use a number that produces the same result on both platforms.

@zainab-ali
Copy link
Contributor Author

Thanks @maekl ! As stated in #108 , I think we could do with a ShowMagnitude typeclass.

I'd be very happy to include ScalaJS. Please feel free to submit a PR for it.

@maekl
Copy link
Contributor

maekl commented Apr 24, 2020

I have submitted a PR. However, I did run into a few issues, mostly around the microsite in combination with cross-compilation. Tried fixing them with minimal dependency upgrades but ran into even more incompatibility issues. I could only make it work by upgrading the Scala versions as well as many other dependencies of the project.

@zainab-ali
Copy link
Contributor Author

This has been merged in 🎉
I'm aiming for a release later today

@zainab-ali
Copy link
Contributor Author

This has been release in v0.7.0. Thanks @maekl !

Please feel free to open a PR and add yourself to the list of contributors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants