Are you interested in building tools for ATS3?

219 views
Skip to first unread message

gmhwxi

unread,
Dec 16, 2019, 11:05:41 PM12/16/19
to ats-lang-users

The full name for ATS3 is ATS/Xanadu.

From this point on, I would use the name 'Xanadu' for ATS3 as this should make it easier
for people to locate information on ATS/Xanadu.

I have so far implemented ATS0 (ATS/Proto),  ATS1 (ATS/Geizella and ATS/Anairiats),
and ATS2 (ATS/Postiats). ATS/Proto and ATS/Geizella were done in OCaml and the others
in ATS1. I now see all of these implementations as parts of a lengthy programming language
experiment spanning a period of about 15 years.

But ATS3 is designed and implemented very differently. First and foremost, I hope that ATS3
can become a programming language suitable for use in production. For that to have a chance to
ever happen, we need to build an ecosystem for ATS3. ATS3 is structured in a way that can
greatly facilitate collaboration of contributors.

While it is still a bit too early for a release of ATS3, I feel that some people may be interested in
playing with the syntax of ATS3 and learning a few tricks about programming language implementation.
With that thought on my mind, I have just implemented a (naive) interpreter for ATS3. Please find the code
for this interpreter in the following repository:


The basic idea is to structure xinterp as a project external to ATS/Xanadu.

After git-cloing xinterp, please also git-clone the following repo inside the xinterp repo:


Please do not modify the code in the xanadu repo; the code in this repo is copied from elsewhere.
You may ask me to do the modification, though.

By studying xinterp (and possibly raising questions here), you can implement all kinds of tools
for processing the syntax of ATS3: syntax-highlighting, pretty-printing, error-messgage-reporting, etc.

Have fun!

--Hongwei

--Hongwei

Kiwamu Okabe

unread,
Dec 17, 2019, 12:19:44 AM12/17/19
to ats-lang-users
Hi,

On Tue, Dec 17, 2019 at 1:05 PM gmhwxi <gmh...@gmail.com> wrote:
> With that thought on my mind, I have just implemented a (naive) interpreter for ATS3. Please find the code
> for this interpreter in the following repository:
>
> https://github.com/xanadu-lang/xinterp
>
> The basic idea is to structure xinterp as a project external to ATS/Xanadu.
>
> After git-cloing xinterp, please also git-clone the following repo inside the xinterp repo:
>
> https://github.com/xanadu-lang/xanadu

Umm...

```
$ pwd
/home/kiwamu/src/xinterp
$ ls ../xanadu/srcgen/xats/SATS
basics.sats effect.sats label0.sats parsing.sats statyp2.sats
t1xread.sats trans23.sats
dynexp0.sats filpath.sats lexbuf.sats staexp0.sats symbol.sats
t2xread.sats trans33.sats
dynexp1.sats filsrch.sats lexing.sats staexp1.sats symenv.sats
t3xread.sats trans3t.sats
dynexp2.sats fixity.sats locinfo.sats staexp2.sats symmap.sats
trans01.sats xerrory.sats
dynexp3.sats global.sats nmspace.sats stamp0.sats synread.sats
trans12.sats
$ make
/home/kiwamu/src/ATS-Postiats/bin/patsopt -o BUILD/intrep0_sats.c
--static SATS/intrep0.sats
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1547(line=47, offs=1) --
1584(line=48, offs=29): error(1): the file
[./../xanadu/srcgen/xats/SATS/basics.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1588(line=50, offs=1) --
1625(line=51, offs=29): error(1): the file
[./../xanadu/srcgen/xats/SATS/label0.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1626(line=52, offs=1) --
1664(line=53, offs=30): error(1): the file
[./../xanadu/srcgen/xats/SATS/filpath.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1665(line=54, offs=1) --
1703(line=55, offs=30): error(1): the file
[./../xanadu/srcgen/xats/SATS/locinfo.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1730(line=59, offs=1) --
1773(line=60, offs=35): error(1): the file
[./../xanadu/srcgen/xats/SATS/lexing.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1800(line=64, offs=1) --
1844(line=65, offs=36): error(1): the file
[./../xanadu/srcgen/xats/SATS/dynexp1.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1848(line=67, offs=1) --
1892(line=68, offs=36): error(1): the file
[./../xanadu/srcgen/xats/SATS/staexp2.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1893(line=69, offs=1) --
1937(line=70, offs=36): error(1): the file
[./../xanadu/srcgen/xats/SATS/statyp2.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1938(line=71, offs=1) --
1982(line=72, offs=36): error(1): the file
[./../xanadu/srcgen/xats/SATS/dynexp2.sats] is not available for
staloading.
/home/kiwamu/src/xinterp/SATS/intrep0.sats: 1986(line=74, offs=1) --
2030(line=75, offs=36): error(1): the file
[./../xanadu/srcgen/xats/SATS/dynexp3.sats] is not available for
staloading.
patsopt(TRANS1): there are [10] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
make: *** [Makefile:72: BUILD/intrep0_sats.c] Error 1
rm BUILD/intrep0_sats.c
```

Best regards,
--
Kiwamu Okabe at METASEPI DESIGN

gmhwxi

unread,
Dec 17, 2019, 1:25:41 AM12/17/19
to ats-lang-users
You were too fast :)

Now it is ready. Please find a session attached to this message.
Basically, I did:

cd /tmp
cd xinterp
make libxatsopt
make xinterp
./bin/xinterp -d TEST/kfact.dats
./bin/xinterp -d TEST/cbref.dats

By the way, there is a lot of debugging info printed out when
you try xinterp. But I hope that interested parties can start to
contribute now...



On Tuesday, December 17, 2019 at 12:19:44 AM UTC-5, Kiwamu Okabe wrote:
Hi,
session-for-building-xinterp.txt

Kiwamu Okabe

unread,
Dec 17, 2019, 1:32:31 AM12/17/19
to ats-lang-users
On Tue, Dec 17, 2019 at 3:25 PM gmhwxi <gmh...@gmail.com> wrote:
> Now it is ready. Please find a session attached to this message.
> Basically, I did:
>
> cd /tmp
> git clone https://github.com/xanadu-lang/xinterp.git
> cd xinterp
> git clone https://github.com/xanadu-lang/xanadu.git
> make libxatsopt
> make xinterp
> ./bin/xinterp -d TEST/kfact.dats
> ./bin/xinterp -d TEST/cbref.dats

I think it works on my PC.
This is my first step to learn ATS3. Thanks.

Richard

unread,
Dec 17, 2019, 1:45:26 AM12/17/19
to ats-lang-users
Opened a pr to add a simple (but convenient) build script https://github.com/xanadu-lang/xinterp/pull/2/files

Richard

unread,
Dec 17, 2019, 2:00:15 AM12/17/19
to ats-lang-users
Now one can do,

git clone https://github.com/xanadu-lang/xinterp.git
cd xinterp
sh build
.sh
./bin/xinterp -d TEST/kfact.dats

Richard

unread,
Dec 17, 2019, 2:02:59 AM12/17/19
to ats-lang-users
By the way, xjsonize is nearly ready to be published! I will publish it following a similar format to xinterp later this evening :)

Chris Double

unread,
Dec 17, 2019, 4:15:45 PM12/17/19
to ats-lan...@googlegroups.com
What version of ATS2 is needed to build it? Using 0.3.13 I get:

$ make libxatsopt
(cd ./xanadu/srcgen/xats && make libxatsopt)
make[1]: Entering directory 'xinterp/xanadu/srcgen/xats'
patsopt -o BUILD/fixity_sats.c --static SATS/fixity.sats
xinterp/xanadu/srcgen/xats/SATS/fixity.sats: 1776(line=62, offs=1) --
1783(line=62, offs=8): error(parsing): the token is discarded.
exit(ATS): uncaught exception:
_2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
make[1]: *** [Makefile:168: BUILD/fixity_sats.c] Error 1

--
https://bluishcoder.co.nz

gmhwxi

unread,
Dec 17, 2019, 5:32:07 PM12/17/19
to ats-lang-users
I used ATS2-0.4.0.

There is only a pre-release of this version accessible at


Here is the direct link to it:

Chris Double

unread,
Dec 17, 2019, 9:22:53 PM12/17/19
to ats-lan...@googlegroups.com
On Wed, Dec 18, 2019 at 11:32 AM gmhwxi <gmh...@gmail.com> wrote:
>
> I used ATS2-0.4.0.

Thanks, that worked for me.

--
https://bluishcoder.co.nz

Richard

unread,
Dec 21, 2019, 4:09:53 AM12/21/19
to ats-lang-users
Here is an other extension example https://github.com/sparverius/xjsonize. (see the readme for building instructions)
Outputs the AST at each transition level in json. This can be helpful for writing other extensions or even just to learn ast.

Dan'l Miller

unread,
Dec 21, 2019, 10:21:48 AM12/21/19
to ats-lang-users
Thank you for providing this extension, Richard.  (And thank you, Hongwei, for being the prime-mover genius of all this; this is like watching Mozart write his symphonies.)

Is it intended that all extensions of Xanadu be placed at the same software-architectural design points as this extension?  Or are there intended to be quite different categories of extensions that are placed in Xanadu's compiler at quite different software-architectural put-stuff-here design points—i.e., “horses for courses” as the British say: different horses are bred for different events/venues?  (I am aware of Hongwei's posting in recent days regarding AST-to-AST-to-…-to-AST transforms as a key microkernel-esque breakthrough design of Xanadu.  Those transforms/ASTs might be part of the answer, but are their more intended put-stuff-here design points?)

gmhwxi

unread,
Dec 21, 2019, 10:25:44 PM12/21/19
to ats-lang-users
Richard,

Thanks for your contribution!

You may want to start a new thread here on xjsonize so as to make it easier
for other people to find it. Also, hope that you could show an example (e.g.,
implementing a calculator of some sort) that makes direct use of xjsonize.

Cheers!

--Hongwei

gmhwxi

unread,
Dec 21, 2019, 11:39:43 PM12/21/19
to ats-lang-users
Thanks for your compliment. It is really difficult to live up to it :)

>>Is it intended that all extensions of Xanadu be placed at the same software-architectural design points as this extension?

What xinterp and xjonsonize show is a typical way to implement a tool for processing or analyzing various syntax trees used
in the implementation of ATS3. For instance, pretty printing can be implemented in this way; error-message reporting of all sorts
can also be implemented in this way. With xjsonize, such tools can actually be written in other languages than ATS2.

However, what gets me really excited is to implement so-called meta-programming extensions. ATS3 is designed to be both a
source language and a target language. And a meta-programming extension of ATS3 is supposed to compile to ATS3, enabling
higher-level programming than what is supported in ATS3. Speaking of programming, I think we must automate and we will automate
(Hilbert's original words are: Wir müssen wissen — wir werden wissen!).

Cheers!

--Hongwei

rodol

unread,
Dec 22, 2019, 8:23:30 AM12/22/19
to ats-lang-users
This is amazing, thank you for all the work you are doing!

If I'm understanding this right, it is going to be possible to make all sorts of language extensions
that hook into various point of the compilation process, allowing for a large variety of functionality.
I can already see the possibility of high level optimization transformations, inline cuda kernel generation,
actual metaprogramming code generation, and so much more. This is powerful...

I am excited. There is much to learn...
I'm still figuring out ATS2, I don't think I can be much help on ATS3 yet :)

gmhwxi

unread,
Dec 22, 2019, 10:27:43 AM12/22/19
to ats-lang-users

Yes.

Sometimes, I see it as a subway train: One can get on and get off
at various points.

Dan'l Miller

unread,
Dec 23, 2019, 2:20:31 PM12/23/19
to ats-lang-users
Hongwei, other than the long list of fine-grained differences between ATS/Postiats and the emerging ATS/Xanadu, what do you think stops ATS/Postiats itself from being “a programming language suitable for use in production”?  For example, the C-source generation could fairly easily have begat an PostiatsAST-to-ClangAST tree-transduction to get an LLVM backend with relatively little effort (or PostiatsAST-to-gimpleAST tree-transduction à la GNAT to get a gcc backend).  I ask this from the perspective of what extensions to ATS/Xanadu would most likely be steps forward versus repeating an impediment-to-production-suitability that AST/Postiats already might have pursued.

gmhwxi

unread,
Dec 24, 2019, 7:59:14 AM12/24/19
to ats-lang-users

What I have learned from the ATS2 experiment is a set of programming features
that I want to have in ATS3 and how these features should be implemented.

Say that we have three features A, B, and C. In ATS2, they are implemented in the
order of A + B + C. What I learned from ATS2 is that the order should really be A + C + B,
that is, C should be implemented before B. Specifically, B is type-checking and C is template
selection. In order to implement C before B, I need to implement another feature B0:
A + B0 + C + B, where B0 is type-inference. This change in implementation order is fundamental.
To appreciate the significant of this change, one could compare Haskell without type classes (ATS2)
with Haskell (ATS3).

The C-source generation issue is relatively minor. It will be properly taken care of in ATS3.

In short, continuing to work on ATS2 is not a good choice because some fundamental changes
in implementation are needed to greatly improve it. Thus, ATS3!

Dan'l Miller

unread,
Dec 24, 2019, 7:12:37 PM12/24/19
to ats-lang-users
Where ≺ is precedes, A ≺ B0 ≺ C ≺ B → ATS/Xanadu is lucid & compact well-presented deep insight.  I had noticed clues & pieces to this effect in past postings but this puts is it together directly.

This progression might be related to something that I have been pondering:  Is the shift away from ATS2's more C-family syntax to ATS3's different ground syntax a direct facilitator of any or all of {A, B0, C, B} or is it an orthogonal choice?

gmhwxi

unread,
Dec 27, 2019, 11:02:55 AM12/27/19
to ats-lang-users

This progression might be related to something that I have been pondering:  Is the shift away from ATS2's more C-family syntax to ATS3's different ground syntax a direct facilitator of any or all of {A, B0, C, B} or is it an orthogonal choice?

To some extent, the answer is yes. With type-inference, ATS3 could readily
support programming of familiar styles to programmers working in industry.
Reply all
Reply to author
Forward
0 new messages