ATS + ReactJS

184 views
Skip to first unread message

gmhwxi

unread,
Nov 22, 2017, 10:04:54 PM11/22/17
to ats-lang-users

I have just got started to use ATS and ReactJS together.

For people who are interested, the following links may be useful:

Demo:

http://ats-lang.github.io/DEMO/React.js/Tic-Tac-Toe/index.html

Source:

https://github.com/githwxi/ATS-Postiats-frozen/tree/master/projects/SMALL/Tic-Tac-Toe-2017-11-22

The setup used in the above Tic-Tac-Toe example should get one started quickly.

I knew very little about ReactJS and got a bit disoriented when trying to using ReactJS to manipulate
states. So I decided to use abstract types in ATS to help me manipulate states. So far so good. I will
try to report more later.

Cheers!

Raoul Duke

unread,
Nov 22, 2017, 10:08:44 PM11/22/17
to ats-lang-users
That is cool. There's some other things that might be worth looking at
as food for thought. (some of these are for React-Native since I am
more on the mobile side, not on the web side...)

Haxe https://github.com/massiveinteractive/haxe-react

Reason https://blog.behrends.io/how-to-setup-reasonml-for-a-react-native-project-8c51f1cc1d34

Rust https://medium.com/@marekkotewicz/building-a-mobile-app-in-rust-and-react-native-part-1-project-setup-b8dbcf3f539f

gmhwxi

unread,
Nov 22, 2017, 10:44:36 PM11/22/17
to ats-lang-users
Thanks for the links!

Will try to find time to do a simple example using ATS and React-native :)

If you are already familiar with React-native, then doing such an example
should be straightforward:

1) Pick a React-native project you did;
2) Take out the logic part and do it in ATS; then compile ATS to JS;
3) Combine the rest of JS code in your project with the JS code generated
    from ATS source.

Cheers!

gmhwxi

unread,
Nov 23, 2017, 11:20:30 PM11/23/17
to ats-lang-users

I did manage to run some JS code generated from ATS in a React-native
project (for printing out factorial numbers). I was actually able to load in the
entire libatscc2js library, and I wrote the factorial function in CPS-style:

//            
implement
fact
(n) = kfact(n, lam(res) => res)
//              
implement
kfact
(n, k) =
if
(n > 0)
then kfact(n-1, lam(res) => k(n*res)) else k(1)
//                            

I will post my code once I can get something more interesting.

In the long run, it may make even more sense to transpile ATS into
Java (instead of JavaScript) for targeting Android.

ATS can already be used with Objective-C. So targeting iOS is
already within reach. One just needs to figure out a way to stream-line it.

Cheers!
Reply all
Reply to author
Forward
0 new messages