for the record, we can do this once we have some basic bindings like React.createElement
[%jsx{|
<div>
... { } ...
</div>
|}]
Should this be implemented as syntax extension, really? I think, in OCaml, one may define functions for html tags and then combine them, in usual manner, smth like — https://github.com/little-arhat/ocaml-fb-react-playground/blob/master/src/core.ml#L173
And why do you want react (and syntax extensions around it) in compiler or stdlib? There are many ways to handle UI, including many ways to handle virtual dom, some of them can be much more efficient in functional context than React (see elm's benchmarks). JaneStreet's guys now have some experiments with mixed approach https://github.com/janestreet/incremental.
For me it looks like that such things definitely should be in different/side projects. And we'll help you, guys, with this stuff after release/beta ;)
hi, thanks for your comments, this is just to raise some ideas,as you can see, I don't have time to implement it in the short term.
but there are benefits of using a jsx syntax, easy to copy paste existing reactjs code and do static analysis
@bobzhang you have "React binding" in Beta roadmap (near "Support goog.module"), so I thought it considered as must-have feature :)
but there are benefits of using a jsx syntax, easy to copy paste existing reactjs code and do static analysis
Yes, and it can be done in library (for who want to copy paste react's code)
(Side note: this is all already implemented: https://github.com/ocsigen/tyxml/)
@Drup thanks for your link, I am aware of tyxml, it is slightly different here, jsx is mainly used for vdom(or react bindings), not for plain html
Tyxml (and its syntax extension) also supports virtual dom via janestreet's bindings (see Virtual_dom.Tyxml). I hope to implement the reactjs API once the bindings stabilizes.
Just to clarify: Tyxml is not limited to textual html, it's a set of combinators that can be implemented on any html structure. For now, it's implemented on textual html (included in tyxml), dom tree (in jsoo), reactive dom trees (in jsoo with ocaml's React), virtual dom (the one I linked above) and client/server dom with reactive elements (in eliom). For all those structures you get the set of combinators, the typechecking and the html syntax extension directly.
maybe delegated https://github.com/facebook/reason/pull/647
close it since reason are working on it
Most helpful comment
Just to clarify: Tyxml is not limited to textual html, it's a set of combinators that can be implemented on any html structure. For now, it's implemented on textual html (included in tyxml), dom tree (in jsoo), reactive dom trees (in jsoo with ocaml's React), virtual dom (the one I linked above) and client/server dom with reactive elements (in eliom). For all those structures you get the set of combinators, the typechecking and the html syntax extension directly.