# Creating a package written in ATS

**URL:** <https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300>\
**Category:** Google Group\
**Created:** [May 22, 2015, 4:18pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300 "2015-05-22T16:18:35Z")\
**Posts on this page:** 14\
**Page:** 1

<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:** [May 22, 2015, 4:18pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/1 "2015-05-22T16:18:35Z")

</div>

I created the following package for use by other projects:

> **[githwxi/ATS-Postiats-contrib](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-parsemit)**
>
> ATS-Postiats-contrib is primarily for packages contributed to ATS-Postiats - githwxi/ATS-Postiats-contrib

Here is an example to show how CATS-parsemit can be used:

[https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js)

Basically, one needs to copy the SATS files provided by CATS-parsemit to a  
local directory, say,  
.CATS-parsemit. In addition, one needs to copy the CATS files generated  
from the ATS source (of CATS-parsemit).  
This can be done by issuing:

make pkgreloc

These CATS files replace the need for library binaries (in the form of .a  
or .so files), thus greatly enhancing portability.

Now just do ‘make all’, and ‘atscc2js’ should be built properly.

---

<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:** [May 22, 2015, 5:08pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/2 "2015-05-22T17:08:07Z")

</div>

> > From `CATS-parsemit` or from `CATS-atscc2js`? I don’t know the `pkgreloc`  
> > target.

In CATS-atscc2jsOn Fri, May 22, 2015 at 12:41 PM, ‘Yannick Duchêne’ via ats-lang-users \< [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com)\> wrote:

> Le vendredi 22 mai 2015 18:18:35 UTC+2, gmhwxi a écrit :
> 
> > […] In addition, one needs to copy the CATS files generated from the ATS  
> > source (of CATS-parsemit).  
> > This can be done by issuing:
> > 
> > make pkgreloc
> 
> From `CATS-parsemit` or from `CATS-atscc2js`? I don’t know the `pkgreloc`  
> target.
> 
> –  
> 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/b62fc6c3-1d12-4935-8b26-90959cd13969%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/b62fc6c3-1d12-4935-8b26-90959cd13969%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/b62fc6c3-1d12-4935-8b26-90959cd13969%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/b62fc6c3-1d12-4935-8b26-90959cd13969%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 22, 2015, 4:41pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/3 "2015-05-22T16:41:51Z")

</div>

> […] In addition, one needs to copy the CATS files generated from the ATS  
> source (of CATS-parsemit).  
> This can be done by issuing:
> 
> make pkgreloc

From `CATS-parsemit` or from `CATS-atscc2js`? I don’t know the `pkgreloc`  
target.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 22, 2015, 6:08pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/4 "2015-05-22T18:08:18Z")

</div>

> Your version of ATS2 is not newer enough 🙂

I have 0.1.12 ☹ Isn’t it the lastest?

I will try to install from GitHub (ATS, not just Contrib), but I feel to  
remember ATS1 is required to build ATS2 from GitHub.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 28, 2015, 9:55pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/5 "2015-05-28T21:55:59Z")

</div>

I see, it’s like encapsulation, but if whatever in a local section cannot  
be used in another part, what’s the intended effect if not side effetcs? Or  
is it about externs? But if so, then what about dynloads?Le jeudi 28 mai 2015 20:52:50 UTC+2, gmhwxi a écrit :

> Well, the point is to make sure that whatever is included in the local  
> sections cannot  
> be used in other parts of the code. However, the compiler still gets to  
> compile the code  
> in local sections. This makes it straightforward to combine several files  
> of ATS code into  
> a single one.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 22, 2015, 5:12pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/6 "2015-05-22T17:12:22Z")

</div>

> 

> > […] In addition, one needs to copy the CATS files generated from the ATS  
> > source (of CATS-parsemit).  
> > This can be done by issuing:
> > 
> > make pkgreloc
> 
> From `CATS-parsemit` or from `CATS-atscc2js`? I don’t know the `pkgreloc`  
> target.

From `CATS-atscc2js` seems to deal with the hidden directory  
`.CATS-parsemit` , this do the same as copying manually and I still have  
compilation errors:

./.CATS-parsemit/catsparse\_include\_all\_dats.c:165072:22: error: ‘  
CATSPARSE\_\_filename\_stdin’ undeclared (first use in this function)  
and  
./.CATS-parsemit/catsparse\_include\_all\_dats.c:165125:22: error: ‘  
CATSPARSE\_\_location\_dummy’ undeclared (first use in this function)

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 22, 2015, 6:15pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/7 "2015-05-22T18:15:04Z")

</div>

OK, I’ve seen there is a newer 0.1.13. Installing from the script I use  
just fetched the previous one.Le vendredi 22 mai 2015 20:08:18 UTC+2, Yannick Duchêne a écrit :

> Le vendredi 22 mai 2015 19:16:42 UTC+2, gmhwxi a écrit :
> 
> > Your version of ATS2 is not newer enough 🙂
> 
> I have 0.1.12 ☹ Isn’t it the lastest?
> 
> I will try to install from GitHub (ATS, not just Contrib), but I feel to  
> remember ATS1 is required to build ATS2 from GitHub.

---

<div class="post-metadata">

**Author:** ![Zhiqiang\_Ren](https://avatars.discourse-cdn.com/v4/letter/z/9fc29f/32.png) [@Zhiqiang\_Ren](https://discourse.ats-lang.org/u/Zhiqiang_Ren)\
**Post date:** [May 28, 2015, 4:08pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/8 "2015-05-28T16:08:25Z")

</div>

Just curious, in catsparse\_include\_all.dats  
[https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse\_include\_all.dats](https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse_include_all.dats),  
why do we need to put “#include xxx” in “local” structure?

Also the link  
[https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js)  
has been changed to  
[https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2jsOn](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2jsOn) Friday, May 22, 2015 at 12:18:35 PM UTC-4, gmhwxi wrote:

> I created the following package for use by other projects:
> 
> [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-parsemit](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-parsemit)
> 
> Here is an example to show how CATS-parsemit can be used:
> 
> [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js)
> 
> Basically, one needs to copy the SATS files provided by CATS-parsemit to a  
> local directory, say,  
> .CATS-parsemit. In addition, one needs to copy the CATS files generated  
> from the ATS source (of CATS-parsemit).  
> This can be done by issuing:
> 
> make pkgreloc
> 
> These CATS files replace the need for library binaries (in the form of .a  
> or .so files), thus greatly enhancing portability.
> 
> Now just do ‘make all’, and ‘atscc2js’ should be built properly.

---

<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:** [May 28, 2015, 11:04pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/9 "2015-05-28T23:04:28Z")

</div>

Just to have all the implements available to the compiler.  
If a file is included, then the dynload for the file is not needed.  
It is kind of being inlined.On Thursday, May 28, 2015 at 5:55:59 PM UTC-4, Yannick Duchêne wrote:

> I see, it’s like encapsulation, but if whatever in a local section cannot  
> be used in another part, what’s the intended effect if not side effetcs? Or  
> is it about externs? But if so, then what about dynloads?
> 
> Le jeudi 28 mai 2015 20:52:50 UTC+2, gmhwxi a écrit :
> 
> > Well, the point is to make sure that whatever is included in the local  
> > sections cannot  
> > be used in other parts of the code. However, the compiler still gets to  
> > compile the code  
> > in local sections. This makes it straightforward to combine several files  
> > of ATS code into  
> > a single one.

---

<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:** [May 28, 2015, 4:14pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/10 "2015-05-28T16:14:48Z")

</div>

This is just to make sure that the contents in these files cannot interfere  
with each other.

If you like, you could also do

val () = let #include “…” in () endOn Thursday, May 28, 2015 at 12:08:25 PM UTC-4, Zhiqiang Ren wrote:

> Just curious, in catsparse\_include\_all.dats  
> [https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse\_include\_all.dats](https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse_include_all.dats),  
> why do we need to put “#include xxx” in “local” structure?
> 
> Also the link
> 
> [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js)  
> has been changed to
> 
> [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2js)
> 
> On Friday, May 22, 2015 at 12:18:35 PM UTC-4, gmhwxi wrote:
> 
> > I created the following package for use by other projects:
> > 
> > [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-parsemit](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-parsemit)
> > 
> > Here is an example to show how CATS-parsemit can be used:
> > 
> > [https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js](https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atscc2js)
> > 
> > Basically, one needs to copy the SATS files provided by CATS-parsemit to  
> > a local directory, say,  
> > .CATS-parsemit. In addition, one needs to copy the CATS files generated  
> > from the ATS source (of CATS-parsemit).  
> > This can be done by issuing:
> > 
> > make pkgreloc
> > 
> > These CATS files replace the need for library binaries (in the form of .a  
> > or .so files), thus greatly enhancing portability.
> > 
> > Now just do ‘make all’, and ‘atscc2js’ should be built properly.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 29, 2015, 3:37am UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/11 "2015-05-29T03:37:00Z")

</div>

> Just to have all the implements available to the compiler.

Okay, I see. So may be unless an application is so big it needs separate  
units to be type-checked within a reasonable amount of time, this may be  
more simple to always use includes in locals.

> If a file is included, then the dynload for the file is not needed.  
> It is kind of being inlined.

Yes, that sounds obvious.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 28, 2015, 5:39pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/12 "2015-05-28T17:39:43Z")

</div>

I have not yet looked at it, but I have a question too: how do one make use  
of what’s included in the local sections, as this is not like a namespace?  
Or is this only for side effects?Le jeudi 28 mai 2015 18:14:48 UTC+2, gmhwxi a écrit :

> This is just to make sure that the contents in these files cannot  
> interfere with each other.
> 
> If you like, you could also do
> 
> val () = let #include “…” in () end
> 
> On Thursday, May 28, 2015 at 12:08:25 PM UTC-4, Zhiqiang Ren wrote:
> 
> > Just curious, in catsparse\_include\_all.dats  
> > [https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse\_include\_all.dats](https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse_include_all.dats),  
> > why do we need to put “#include xxx” in “local” structure?

---

<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:** [May 28, 2015, 6:52pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/13 "2015-05-28T18:52:50Z")

</div>

Well, the point is to make sure that whatever is included in the local  
sections cannot  
be used in other parts of the code. However, the compiler still gets to  
compile the code  
in local sections. This makes it straightforward to combine several files  
of ATS code into  
a single one.On Thursday, May 28, 2015 at 1:39:43 PM UTC-4, Yannick Duchêne wrote:

> I have not yet looked at it, but I have a question too: how do one make  
> use of what’s included in the local sections, as this is not like a  
> namespace? Or is this only for side effects?
> 
> Le jeudi 28 mai 2015 18:14:48 UTC+2, gmhwxi a écrit :
> 
> > This is just to make sure that the contents in these files cannot  
> > interfere with each other.
> > 
> > If you like, you could also do
> > 
> > val () = let #include “…” in () end
> > 
> > On Thursday, May 28, 2015 at 12:08:25 PM UTC-4, Zhiqiang Ren wrote:
> > 
> > > Just curious, in catsparse\_include\_all.dats  
> > > [https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse\_include\_all.dats](https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-parsemit/catsparse_include_all.dats),  
> > > why do we need to put “#include xxx” in “local” structure?

---

<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:** [May 22, 2015, 5:16pm UTC](https://discourse.ats-lang.org/t/creating-a-package-written-in-ats/300/14 "2015-05-22T17:16:42Z")

</div>

Your version of ATS2 is not newer enough :)On Fri, May 22, 2015 at 1:12 PM, ‘Yannick Duchêne’ via ats-lang-users \< [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com)\> wrote:

> Le vendredi 22 mai 2015 18:41:51 UTC+2, Yannick Duchêne a écrit :
> 
> > Le vendredi 22 mai 2015 18:18:35 UTC+2, gmhwxi a écrit :
> > 
> > > […] In addition, one needs to copy the CATS files generated from the ATS  
> > > source (of CATS-parsemit).  
> > > This can be done by issuing:
> > > 
> > > make pkgreloc
> > 
> > From `CATS-parsemit` or from `CATS-atscc2js`? I don’t know the `pkgreloc`  
> > target.
> 
> From `CATS-atscc2js` seems to deal with the hidden directory  
> `.CATS-parsemit` , this do the same as copying manually and I still have  
> compilation errors:
> 
> ./.CATS-parsemit/catsparse\_include\_all\_dats.c:165072:22: error: ‘  
> CATSPARSE\_\_filename\_stdin’ undeclared (first use in this function)  
> and  
> ./.CATS-parsemit/catsparse\_include\_all\_dats.c:165125:22: error: ‘  
> CATSPARSE\_\_location\_dummy’ undeclared (first use in this function)
> 
> –  
> 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/fe4ab684-0185-4342-9c77-0d18436a3239%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/fe4ab684-0185-4342-9c77-0d18436a3239%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/fe4ab684-0185-4342-9c77-0d18436a3239%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/fe4ab684-0185-4342-9c77-0d18436a3239%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
