Solid: Question regarding the support of Flow lang or ReasonML/ReScript

Created on 21 Oct 2020  路  5Comments  路  Source: ryansolid/solid

I really love this framework and plan to use it for some middle sized project, but using TypeScript is a bit of a letdown to me 馃槥

Is there any (planned) support for Flow lang or ReasonML (official or unofficial)?

It feels like ReasonML _could_ be supported somehow but I wonder how some features, like currying, would work with the Solid "transpiler" 馃槙

question

Most helpful comment

Thank you very much @ryansolid

Well it's only the JSX that is transpiled.

That's very good to know, if only the jsx code is transpiled, it means compiling OCaml/ReasonML to JS _and_ preserving the jsx _could_ work. I might give it a try soon. I think I read somewhere it was doable, but I couldn't find the documentation (yet).

I will give it a try as soon as possible, and try to report here if I can make it work somehow 馃槃

All 5 comments

Well it's only the JSX that is transpiled. And it is a very custom compilation. One that I suspect would not be supported by ReasonML, but I'm not 100% on that. The way it works cannot be reduced into simple function calls and I morph not just the elements but the attributes as well.

That being said I do have support for HyperScript. It doesn't leverage most of the benefits of the JSX compiler but it does have the advantage here of boiling down to a simple h function. So from that perspective there could be a version where you manually wrap your expressions and the integration could generally be the same as library like Preact. Although the HyperScript is less mature and doesn't support SSR yet etc and is just for the browser.

I have no knowledge of ReasonML and not being able to leverage the custom transforms definitely would dampen my personal enthusiasm. But it definitely isn't off the table. I'm not aware of anyone working on this as of yet. For someone who knows ReasonML I think a simple integration would not be too difficult and I'd be willing to help answer any questions to help make it posssible.

Thank you very much @ryansolid

Well it's only the JSX that is transpiled.

That's very good to know, if only the jsx code is transpiled, it means compiling OCaml/ReasonML to JS _and_ preserving the jsx _could_ work. I might give it a try soon. I think I read somewhere it was doable, but I couldn't find the documentation (yet).

I will give it a try as soon as possible, and try to report here if I can make it work somehow 馃槃

Something like Solid or Svelte for ReasonML would be fantastic! :)

@gaku-sei: as far as I remember, you just can embed JavaScript into Reason. But I'm not sure if Reason would allow JSX there. Even if it does, however, JSX isn't valid JavaScript, so you'd have to compile the output from Reason to JavaScript (so basically, there would three compile phases with Solid, which probably isn't great).

The easiest approach probably would be to just put Solid code into a separate .js file and import things from Reason.

@ryansolid: You should have look at ReasonML/OCaml. I think it's a fantastic language (in many ways better than TypeScript). I would be astonished if you don't like ReasonML/OCaml, to be honest.

@d4h0

The easiest approach probably would be to just put Solid code into a separate .js file and import things from Reason.
This seems to be indeed the easiest approach so far 馃槙

After trying a bit yesterday, i could make this Gist and it _partly_ works: https://gist.github.com/gaku-sei/8e1d157682379d2bafc4b6dc4e080091

So far, here are some things I noticed:

  • We must use the uncurried function syntax
  • It seems JSX cannot be preserved when compiling down to JS (I opened this issue: https://github.com/rescript-lang/rescript-compiler/issues/4783)
  • But we can use hyperscript (provided we write a ppx for it ^^)
  • The rest seems to be work ok, since as @ryansolid noticed, the Solid compiler doesn't transform anything else.

Well that's good. HyperScript means you need to wrap expressions in functions yourself but otherwise should work. This is pretty exciting. There is definitely some interest here, I've just do not have experience with ReasonML. I have some HyperScript examples.. There is a TodoList example in the examples section. See it here: https://codesandbox.io/s/0vmjlmq94v

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samadadi picture samadadi  路  7Comments

trusktr picture trusktr  路  3Comments

tehdarthvid picture tehdarthvid  路  5Comments

trueadm picture trueadm  路  4Comments

praneybehl picture praneybehl  路  6Comments