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

[Feature Request] Support the JVM (for scalajs interop) #497

Open
robmwalsh opened this issue Nov 10, 2022 · 1 comment
Open

[Feature Request] Support the JVM (for scalajs interop) #497

robmwalsh opened this issue Nov 10, 2022 · 1 comment

Comments

@robmwalsh
Copy link

I've been working on a language server implementation. The corresponding vscode extension is written in scala.js using ScalablyTyped which has for the most part ( #463 aside) is working brilliantly.

The server is written in scala running on the JVM which is very sad because while ScalablyTyped has generated facades for all of these types which are now flying over the wire towards my server (LSP uses JSONRPC 2.0 for comms), I'm now needing to write case classes which essentially correspond 1:1 to the ScalablyTyped facades which are sitting unused just out of reach. I'm also doing nasty hacks to make json decoders/encoders behave how I need them to.

I'm wondering if it's even in the realms of possibility? It strikes me as something that could be fairly easy or near impossible depending how scalably typed works behind the scenes.

@oyvindberg
Copy link
Collaborator

Yeah, this would absolutely be possible. Some work, but certainly possible.

Basically we could use the flavour subsystem, which is just a function from AST to AST which enables you to do arbitrary rewrites and generate arbitrary scala code based on the imported type descriptions. The Scala AST itself is powerful enough to express all the most common syntax, and could be extended if needed. An example transformation is GenCompanions which is responsible for generating companion objects with apply methods for types we can instantiate.

For an example of what a more powerful transformation can do, here is a ActionButton react component syntax thing, based on libUtilActionButtonMod

I guess some problems will show up:

  • we'll need json codecs. I guess there will be some type juggling to get it all to line up
  • json codecs may be especially hard for untagged union types

There is no infrastructure to generate both a scalajs jar and a scala jar. Could save some time here by copy/pasting source code I guess.

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

2 participants