# Formal specification of ATS2 abstract syntax tree (Template ATS2?)

**URL:** <https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347>\
**Category:** Google Group\
**Created:** [October 24, 2014, 12:28am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347 "2014-10-24T00:28:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shea\_Levy](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Shea\_Levy](https://discourse.ats-lang.org/u/Shea_Levy)\
**Post date:** [October 24, 2014, 12:28am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/1 "2014-10-24T00:28:25Z")

</div>

Hi all,

I was wondering, would it be possible to model the ATS2 abstract syntax  
tree as ATS2 types, and use that to implement the ATS2 version of  
Template Haskell? What would be involved in that kind of project, where  
would I start?

Cheers,  
Shea

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [October 24, 2014, 1:17am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/2 "2014-10-24T01:17:11Z")

</div>

I am very glad that you brought up the issue.

Note that the keywords “`(” and “,(” and “%(” are still kept  
in ATS2 in the hope of supporting TH-style of meta-programming 🙂

I co-authored the following paper about 10 years ago:

[http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf)

I actually implemented in ATSproto, the first released version of  
ATS, the system formalized in the above paper, which is more  
ambitious than Template Haskell (TH) in terms of type-checking.

By the way, ATSproto also supported OOP; it was really messy and bulky 🙂

If you are interested, I would suggest that you target only the functional  
core of  
ATS at first. There may be complications due to the support for flat data  
representation  
in ATS2.

Static typechecking is wonderful, but it is often too complicated for such  
a template  
system. So trying to support run-time typechecking on generated syntax  
trees seems  
to be sensible way to control complexity.

Lastly, I would like to point out the following paper:

[http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf)

which is about distributed meta-programming. It is a quite interesting idea.On Thu, Oct 23, 2014 at 8:28 PM, Shea Levy [sh...@shealevy.com](mailto:sh...@shealevy.com) wrote:

> Hi all,
> 
> I was wondering, would it be possible to model the ATS2 abstract syntax  
> tree as ATS2 types, and use that to implement the ATS2 version of  
> Template Haskell? What would be involved in that kind of project, where  
> would I start?
> 
> Cheers,  
> Shea
> 
> –  
> 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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](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/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net)  
> .

---

<div class="post-metadata">

**Author:** ![Artyom\_Shalkhakov](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Artyom\_Shalkhakov](https://discourse.ats-lang.org/u/Artyom_Shalkhakov)\
**Post date:** [October 24, 2014, 3:33am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/3 "2014-10-24T03:33:04Z")

</div>

Hello Shea,

> Hi all,
> 
> I was wondering, would it be possible to model the ATS2 abstract syntax  
> tree as ATS2 types, and use that to implement the ATS2 version of  
> Template Haskell? What would be involved in that kind of project, where  
> would I start?

I don’t know. Just wanted to chime in and wish you good luck. 🙂

I was recently thinking of using metaprogramming together with external  
constraint solving to allow for type-safe database queries in ATS, in the  
style of Ur/Web. Basically, add new external sorts “row” and “field label”,  
and a few external static functions for constructing row sorts, and then  
implement some data structures that would be indexed by these sorts. The  
disjointness proofs of record field labels would be handled externally.

At first, I was thinking of using some form of a preprocessor for this. But  
TH-style metaprogramming would be much easier to deal with, I assume.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [November 3, 2014, 12:45am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/4 "2014-11-03T00:45:24Z")

</div>

Today, I located ATS0-proto. It is now available on-line:

> **[ATS-first](https://sourceforge.net/projects/ats-first/)**
>
> Download ATS-first for free. Unleashing the potentials of types and templates. ATS is a programming language equipped with a highly expressive type system rooted in the framework Applied Type System to unify implementation with formal specification....

The interpreter for ATS0 is contained in the following file:  
[https://sourceforge.net/p/ats-first/code/ci/master/tree/atsInterp.ml](https://sourceforge.net/p/ats-first/code/ci/master/tree/atsInterp.ml)  
[https://sourceforge.net/p/ats-first/code/ci/master/tree/atsInterp.ml](https://sourceforge.net/p/ats-first/code/ci/master/tree/atsInterp.ml)

It does handle the kind of meta-programming we talked about above.On Monday, October 27, 2014 8:23:00 PM UTC-4, gmhwxi wrote:

> Essentially, the core consists of
> 
> lambda-calculus + datatypes + references.
> 
> On Monday, October 27, 2014 7:07:10 PM UTC-4, Shea Levy wrote:
> 
> > On Thu, Oct 23, 2014 at 09:17:11PM -0400, Hongwei Xi wrote:
> > 
> > > I am very glad that you brought up the issue.
> > > 
> > > Note that the keywords “`(” and “,(” and “%(” are still kept  
> > > in ATS2 in the hope of supporting TH-style of meta-programming 🙂
> > > 
> > > I co-authored the following paper about 10 years ago:
> > > 
> > > [http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf)
> > > 
> > > I actually implemented in ATSproto, the first released version of  
> > > ATS, the system formalized in the above paper, which is more  
> > > ambitious than Template Haskell (TH) in terms of type-checking.
> > > 
> > > By the way, ATSproto also supported OOP; it was really messy and bulky  
> > > 🙂
> > > 
> > > If you are interested, I would suggest that you target only the  
> > > functional  
> > > core of  
> > > ATS at first. There may be complications due to the support for flat  
> > > data  
> > > representation  
> > > in ATS2.
> > 
> > What consists of the ‘core’ here?
> > 
> > > Static typechecking is wonderful, but it is often too complicated for  
> > > such  
> > > a template  
> > > system. So trying to support run-time typechecking on generated syntax  
> > > trees seems  
> > > to be sensible way to control complexity.
> > > 
> > > Lastly, I would like to point out the following paper:
> > > 
> > > [http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf)
> > > 
> > > which is about distributed meta-programming. It is a quite interesting  
> > > idea.
> > > 
> > > On Thu, Oct 23, 2014 at 8:28 PM, Shea Levy [sh...@shealevy.com](mailto:sh...@shealevy.com) wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I was wondering, would it be possible to model the ATS2 abstract  
> > > > syntax  
> > > > tree as ATS2 types, and use that to implement the ATS2 version of  
> > > > Template Haskell? What would be involved in that kind of project,  
> > > > where  
> > > > would I start?
> > > > 
> > > > Cheers,  
> > > > Shea
> > > > 
> > > > –  
> > > > 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](mailto:ats-lang...@googlegroups.com).  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > > Visit this group at [http://groups.google.com/group/ats-lang-users](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/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net)
> > 
> > > > .
> > > 
> > > –  
> > > 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](mailto:ats-lang...@googlegroups.com).  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).  
> > > Visit this group at [http://groups.google.com/group/ats-lang-users](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/CAPPSPLpadySc9iA4FsJ5vsmFvLFEo3GgbpTk5cggMTs43TpUyg%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpadySc9iA4FsJ5vsmFvLFEo3GgbpTk5cggMTs43TpUyg%40mail.gmail.com).

---

<div class="post-metadata">

**Author:** ![Shea\_Levy](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Shea\_Levy](https://discourse.ats-lang.org/u/Shea_Levy)\
**Post date:** [October 27, 2014, 11:07pm UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/5 "2014-10-27T23:07:07Z")

</div>

> I am very glad that you brought up the issue.
> 
> Note that the keywords “`(” and “,(” and “%(” are still kept  
> in ATS2 in the hope of supporting TH-style of meta-programming 🙂
> 
> I co-authored the following paper about 10 years ago:
> 
> [http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf)
> 
> I actually implemented in ATSproto, the first released version of  
> ATS, the system formalized in the above paper, which is more  
> ambitious than Template Haskell (TH) in terms of type-checking.
> 
> By the way, ATSproto also supported OOP; it was really messy and bulky 🙂
> 
> If you are interested, I would suggest that you target only the functional  
> core of  
> ATS at first. There may be complications due to the support for flat data  
> representation  
> in ATS2.

What consists of the ‘core’ here?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [October 28, 2014, 12:23am UTC](https://discourse.ats-lang.org/t/formal-specification-of-ats2-abstract-syntax-tree-template-ats2/347/6 "2014-10-28T00:23:00Z")

</div>

Essentially, the core consists of

lambda-calculus + datatypes + references.On Monday, October 27, 2014 7:07:10 PM UTC-4, Shea Levy wrote:

> On Thu, Oct 23, 2014 at 09:17:11PM -0400, Hongwei Xi wrote:
> 
> > I am very glad that you brought up the issue.
> > 
> > Note that the keywords “`(” and “,(” and “%(” are still kept  
> > in ATS2 in the hope of supporting TH-style of meta-programming 🙂
> > 
> > I co-authored the following paper about 10 years ago:
> > 
> > [http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/JFPmp.pdf)
> > 
> > I actually implemented in ATSproto, the first released version of  
> > ATS, the system formalized in the above paper, which is more  
> > ambitious than Template Haskell (TH) in terms of type-checking.
> > 
> > By the way, ATSproto also supported OOP; it was really messy and bulky  
> > 🙂
> > 
> > If you are interested, I would suggest that you target only the  
> > functional  
> > core of  
> > ATS at first. There may be complications due to the support for flat  
> > data  
> > representation  
> > in ATS2.
> 
> What consists of the ‘core’ here?
> 
> > Static typechecking is wonderful, but it is often too complicated for  
> > such  
> > a template  
> > system. So trying to support run-time typechecking on generated syntax  
> > trees seems  
> > to be sensible way to control complexity.
> > 
> > Lastly, I would like to point out the following paper:
> > 
> > [http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf](http://www.cs.bu.edu/~hwxi/academic/papers/gpce06.pdf)
> > 
> > which is about distributed meta-programming. It is a quite interesting  
> > idea.
> > 
> > On Thu, Oct 23, 2014 at 8:28 PM, Shea Levy \<[sh...@shealevy.com](mailto:sh...@shealevy.com) \<javascript:\>\> wrote:
> > 
> > > Hi all,
> > > 
> > > I was wondering, would it be possible to model the ATS2 abstract  
> > > syntax  
> > > tree as ATS2 types, and use that to implement the ATS2 version of  
> > > Template Haskell? What would be involved in that kind of project,  
> > > where  
> > > would I start?
> > > 
> > > Cheers,  
> > > Shea
> > > 
> > > –  
> > > 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](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)  
> > > \<javascript:\>.  
> > > Visit this group at [http://groups.google.com/group/ats-lang-users](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/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20141024002825.GB2093%40nixos.hsd1.nh.comcast.net)
> 
> > > .
> > 
> > –  
> > 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](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)  
> > \<javascript:\>.  
> > Visit this group at [http://groups.google.com/group/ats-lang-users](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/CAPPSPLpadySc9iA4FsJ5vsmFvLFEo3GgbpTk5cggMTs43TpUyg%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpadySc9iA4FsJ5vsmFvLFEo3GgbpTk5cggMTs43TpUyg%40mail.gmail.com).
