From ATS to JavaScript

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(’./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!

Now the code generator (atscc2js) from ATS2 to JavaScript starts to be
functioning.
Here are some simple tests:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript/TESTOn Friday, August 22, 2014 2:58:09 PM UTC-4, gmhwxi wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!

http://www.ats-lang.org/COMPILED/doc/PROJECT/MEDIUM/ATS-parse-emit/JavaScript/mytest.html

so would you catch exceptions and stuff? like, ackermann of easily leads to:
Uncaught RangeError: Maximum call stack size exceeded
:slight_smile:

warning: this comment can easily be interpreted to mean the compiler
is slow, taking 19+ hours to compile! pretty please reword it to avoid
fudding ats2js. :slight_smile: (and even possibly do include the actual
compilation time stats.)

/*
** The JavaScript code is generated by atscc2js
** The compilation time is: 2014-8-27: 19h:27m
*/

Why not target asm.js rather than javascript proper?

martinOn Fri, Aug 22, 2014 at 11:58 AM, gmhwxi gmh...@gmail.com wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com?utm_medium=email&utm_source=footer
.

This is the first I’ve heard of WebAssembly;
The web is getting its bytecode: WebAssembly – OSnews

Looks like it is quite a ways from even a draft spec for now.

I though “another ASM‑JS” , but it looks relevant, as the W2C is involved:
https://www.w3.org/community/webassembly/

Probably not available by tomorrow anyway, as we still don’t even have full
HTML5 support while it’s promoted since long.

What ever, nice to know this initiative exists.

not_null is a template, and it is never implemented.

Oops, my apologizes. Indeed, turning it into this, there is no more issue:
extern fun not_null{r: reference}(r: reference r): bool(not_null(r))

Sometime I wish the syntax for template declarations also use the “<>”
pair instead of the “{}” quantifier pair.

Yes, TCO is implemented for JS.On Wednesday, May 20, 2015 at 2:21:38 PM UTC-4, Brandon Barker wrote:

Related to this, did you have to implement TCO directly in atscc2js (I
ask also because I assume this would need to be done for atscc2java)?

On Wed, May 20, 2015 at 2:11 PM, Brandon Barker <brand...@gmail.com <javascript:>> wrote:

Exciting. If I understand based on your previous assessment, atscc2js
would probably be the best existing template for a atscc2java?

While there are multiple paths to target the JVM, I’m guessing that
having an atscc2java is the most reasonable for the moment, and will
probably still generate fairly performant code.

My medium term plans would be to write atscc2java, then convert
IntelliJATS to it … I hope this might generate more interest for
others in the community as well, but I would say my primary reason is
to just have something to program ATS in, and this seems to be some
potentially nice synergy.

On Wed, May 20, 2015 at 2:03 PM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:

Okay, I added a quick fix.

I am in the process of restructuring atscc2js. I will have something
more
modular soon.

On Wed, May 20, 2015 at 1:38 PM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:

Because it has never been implemented. I will fix it shortly.

On Wed, May 20, 2015 at 12:50 PM, ‘Yannick Duchêne’ via ats-lang-users <ats-l...@googlegroups.com <javascript:>> wrote:

Le vendredi 22 août 2014 20:58:09 UTC+2, gmhwxi a écrit :

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example
I
had:
[…]

Not a big issue, just a bit annoying, atscc2js does not output the
file
name with its error messages (or it’s just with me?), just the
“line=”/“offs=”.


You received this message because you are subscribed to the Google
Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/ats-lang-users/74394103-20ec-443e-b424-18767c75bb62%40googlegroups.com.


You received this message because you are subscribed to the Google
Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLo053PGnhnv5%3Dw-1BsfaA82DL7Ugk216yAzaTgzBBduaw%40mail.gmail.com.


Brandon Barker
brand...@gmail.com <javascript:>


Brandon Barker
brand...@gmail.com <javascript:>

Fixed this one. Thanks!On Wednesday, August 27, 2014 8:09:31 PM UTC-4, Raoul Duke wrote:

http://www.ats-lang.org/COMPILED/doc/PROJECT/MEDIUM/ATS-parse-emit/JavaScript/mytest.html

so would you catch exceptions and stuff? like, ackermann of easily leads
to:
Uncaught RangeError: Maximum call stack size exceeded
:slight_smile:

Done. Here is the current output for the same example:

function
fact(arg0)
{
//

var tmpret0
var tmp1
var tmp2
var tmp3
//

// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
} // end-of-functionOn Saturday, August 23, 2014 10:58:16 AM UTC-4, Artyom Shalkhakov wrote:

Hongwei,

On Saturday, August 23, 2014 12:58:09 AM UTC+6, gmhwxi wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

Could you please emit variable declarations? JS has a funny notion of
scope (where all local variables are hoisted to the top of the enclosing
function), but reading code where variables are not declared prior to use
is puzzling.

Great work!

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:
[…]

Not a big issue, just a bit annoying, atscc2js does not output the file
name with its error messages (or it’s just with me?), just the
“line=”/“offs=”.

Okay, I added a quick fix.

I am in the process of restructuring atscc2js. I will have something more
modular soon.

Ok, so I will wait before looking at ATSCC2JS again. It happans I was
talking about the messages content, because I wanted to try to change some
things (did not tell, as I’m not sure it’s right or wrong), and for that
purpose, it’s easier to the have filenames in the messages.

I think I know what the problem is. I will try to fix it later today.On Friday, May 22, 2015 at 11:39:44 AM UTC-4, Yannick Duchêne wrote:

Le vendredi 22 août 2014 20:58:09 UTC+2, gmhwxi a écrit :

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

[…]

Just to notice, as I will try to look at it myself when the new version of
ATSCC2JS will be available:

There seems to still be an issue with dynload, precisely with duplicated
definitions.

Here is the test:

test-1.dats
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME “js_main_dynload”

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

staload NS = “test-2.dats”
dynload “test-2.dats”
val y = $NS.x + “b”

(JS)
%{$
js_main_dynload();
%}

test-2.dats
#define ATS_MAINATSFLAG 1

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

extern val x: string
implement x = “a”

Closure (the JS compiler/minifier) complains:
./test-2.js:10: WARNING - Redeclared variable: […]_dats__dynloadflag
var […]_dats__dynloadflag = 0;
^
./test-2.js:10: ERROR - Variable […]_dats__dynloadflag first declared in
./test-1.js
var […]_dats__dynloadflag = 0;
^
1 error(s), 1 warning(s)

I wanted to have a look at it yesterday, but had an issue compiling the
new ATSCCJS, so will wait before looking at it.

Okay, I think I have fixed this issue,

The changes are now in ATS2-github.

By the way, I feel that it is a good practice to try to generate
only a single C or JS file from several ATS source files. This is
actually quite easy to do. For instance, see CATS-parsemit for a
good example.On Friday, May 22, 2015 at 12:41:11 PM UTC-4, gmhwxi wrote:

I think I know what the problem is. I will try to fix it later today.

On Friday, May 22, 2015 at 11:39:44 AM UTC-4, Yannick Duchêne wrote:

Le vendredi 22 août 2014 20:58:09 UTC+2, gmhwxi a écrit :

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

[…]

Just to notice, as I will try to look at it myself when the new version
of ATSCC2JS will be available:

There seems to still be an issue with dynload, precisely with duplicated
definitions.

Here is the test:

test-1.dats
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME “js_main_dynload”

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

staload NS = “test-2.dats”
dynload “test-2.dats”
val y = $NS.x + “b”

(JS)
%{$
js_main_dynload();
%}

test-2.dats
#define ATS_MAINATSFLAG 1

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

extern val x: string
implement x = “a”

Closure (the JS compiler/minifier) complains:
./test-2.js:10: WARNING - Redeclared variable: […]_dats__dynloadflag
var […]_dats__dynloadflag = 0;
^
./test-2.js:10: ERROR - Variable […]_dats__dynloadflag first declared in
./test-1.js
var […]_dats__dynloadflag = 0;
^
1 error(s), 1 warning(s)

I wanted to have a look at it yesterday, but had an issue compiling the
new ATSCCJS, so will wait before looking at it.

Hongwei,

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

Could you please emit variable declarations? JS has a funny notion of scope
(where all local variables are hoisted to the top of the enclosing
function), but reading code where variables are not declared prior to use
is puzzling.

Great work!

This is my first try of using JS code generated by atscc2js:

http://www.ats-lang.org/COMPILED/doc/PROJECT/MEDIUM/ATS-parse-emit/JavaScript/mytest.html

Cheers!

–HongweiOn Saturday, August 23, 2014 11:36:15 AM UTC-4, gmhwxi wrote:

See support for datatypes and pattern matching:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/ATS-parse-emit/JavaScript/TEST/listlen.dats

See support for templates and closures:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/ATS-parse-emit/JavaScript/TEST/twice.dats

There is currently no support for exceptions yet.

On Friday, August 22, 2014 2:58:09 PM UTC-4, gmhwxi wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

[…]

Just to notice, as I will try to look at it myself when the new version of
ATSCC2JS will be available:

There seems to still be an issue with dynload, precisely with duplicated
definitions.

Here is the test:

test-1.dats
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME “js_main_dynload”

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

staload NS = “test-2.dats”
dynload “test-2.dats”
val y = $NS.x + “b”

(JS)
%{$
js_main_dynload();
%}

test-2.dats
#define ATS_MAINATSFLAG 1

#include “share/atspre_define.hats”
#include “{$LIBATSCC2JS}/staloadall.hats”

extern val x: string
implement x = “a”

Closure (the JS compiler/minifier) complains:
./test-2.js:10: WARNING - Redeclared variable: […]_dats__dynloadflag
var […]_dats__dynloadflag = 0;
^
./test-2.js:10: ERROR - Variable […]_dats__dynloadflag first declared in ./
test-1.js
var […]_dats__dynloadflag = 0;
^
1 error(s), 1 warning(s)

I wanted to have a look at it yesterday, but had an issue compiling the new
ATSCCJS, so will wait before looking at it.

Related to this, did you have to implement TCO directly in atscc2js (I
ask also because I assume this would need to be done for atscc2java)?On Wed, May 20, 2015 at 2:11 PM, Brandon Barker brandon...@gmail.com wrote:

Exciting. If I understand based on your previous assessment, atscc2js
would probably be the best existing template for a atscc2java?

While there are multiple paths to target the JVM, I’m guessing that
having an atscc2java is the most reasonable for the moment, and will
probably still generate fairly performant code.

My medium term plans would be to write atscc2java, then convert
IntelliJATS to it … I hope this might generate more interest for
others in the community as well, but I would say my primary reason is
to just have something to program ATS in, and this seems to be some
potentially nice synergy.

On Wed, May 20, 2015 at 2:03 PM, Hongwei Xi gmh...@gmail.com wrote:

Okay, I added a quick fix.

I am in the process of restructuring atscc2js. I will have something more
modular soon.

On Wed, May 20, 2015 at 1:38 PM, Hongwei Xi gmh...@gmail.com wrote:

Because it has never been implemented. I will fix it shortly.

On Wed, May 20, 2015 at 12:50 PM, ‘Yannick Duchêne’ via ats-lang-users ats-lan...@googlegroups.com wrote:

Le vendredi 22 août 2014 20:58:09 UTC+2, gmhwxi a écrit :

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I
had:
[…]

Not a big issue, just a bit annoying, atscc2js does not output the file
name with its error messages (or it’s just with me?), just the
“line=”/“offs=”.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/74394103-20ec-443e-b424-18767c75bb62%40googlegroups.com.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLo053PGnhnv5%3Dw-1BsfaA82DL7Ugk216yAzaTgzBBduaw%40mail.gmail.com.


Brandon Barker
brandon...@gmail.com

Brandon Barker
brandon...@gmail.com

Will do it later. It probably just needs some compilation flags.

For now, I’d like to experiment co-programming with ATS and Node.js.On Friday, August 22, 2014 3:18:21 PM UTC-4, Martin DeMello wrote:

Why not target asm.js rather than javascript proper?

martin

On Fri, Aug 22, 2014 at 11:58 AM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com?utm_medium=email&utm_source=footer
.

See support for datatypes and pattern matching:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/ATS-parse-emit/JavaScript/TEST/listlen.dats

See support for templates and closures:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/ATS-parse-emit/JavaScript/TEST/twice.dats

There is currently no support for exceptions yet.On Friday, August 22, 2014 2:58:09 PM UTC-4, gmhwxi wrote:

Okay, I have got the ball rolling:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript

I am currently targeting Node.js. This is the first running example I had:

/* ATSextcode_beg() */
// COMMENT_line

// COMMENT_line

// COMMENT_line

var fs = require(‘fs’);
eval(fs.readFileSync(‘./…/prelude/CATS/integer_cats.js’).toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact

tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif

return tmpret0
}

/* ATSextcode_beg() /
console.log("fact(10) = ", fact(10))
/
ATSextcode_end() */

For being used as a target language, I have to say that JS is a lot more
accommodating than Python.

Be happy to hear comments and suggestions.

Cheers!