# Helping to flesh out ATSLIB in ATS2

**URL:** <https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243>\
**Category:** Google Group\
**Created:** [January 15, 2014, 1:25am UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243 "2014-01-15T01:25:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [January 15, 2014, 1:25am UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/1 "2014-01-15T01:25:41Z")

</div>

There are a lot of nice library functions and succinct algorithms in ATS1’s  
ATSLIB, while at the same time, many of these seem to be implemented in  
ATS2 using templates where possible.  
It can be helpful to check one’s understanding of the ATS1 code by  
inspection and modification before attempting to port to ATS2.

One alternative is to use version control, but others may prefer to copy  
and paste code into a single file with included tests. This may involve  
copy from several files though.  
I’ve put an example [https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
free to improve it or suggest changes.

Currently, there is a problem with the termination metric though (I don’t  
know why yet).

---

<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:** [January 15, 2014, 3:33pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/2 "2014-01-15T15:33:18Z")

</div>

The ‘ref’ in cloref does not mean ref-effect.

I suggest that you do not track effects as doing so is not very meaningful  
in this case.  
Use cloref1 instead of cloref.On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:

> There are a lot of nice library functions and succinct algorithms in  
> ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> in ATS2 using templates where possible.  
> It can be helpful to check one’s understanding of the ATS1 code by  
> inspection and modification before attempting to port to ATS2.
> 
> One alternative is to use version control, but others may prefer to copy  
> and paste code into a single file with included tests. This may involve  
> copy from several files though.  
> I’ve put an example [https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> free to improve it or suggest changes.
> 
> Currently, there is a problem with the termination metric though (I don’t  
> know why yet).

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [January 15, 2014, 5:03pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/3 "2014-01-15T17:03:22Z")

</div>

That is good to know about (anything with a $ seems to be really handy).

I was trying to avoid using cloref1 or \<1\> cause I get:  
error(3): the effects [exn, ntm] are disallowed

and it seemed easier to worry about 1 eff rather than 3.

Unfortunately, even with effmask\_all, the termination metric problem still  
occurs if the print\_lvt statement is uncommented.[https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab](https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab)On Wednesday, January 15, 2014 10:38:32 AM UTC-5, gmhwxi wrote:

> you can use $effmask\_all(print(…)) to mask effects.
> 
> On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:
> 
> > There are a lot of nice library functions and succinct algorithms in  
> > ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> > in ATS2 using templates where possible.  
> > It can be helpful to check one’s understanding of the ATS1 code by  
> > inspection and modification before attempting to port to ATS2.
> > 
> > One alternative is to use version control, but others may prefer to copy  
> > and paste code into a single file with included tests. This may involve  
> > copy from several files though.  
> > I’ve put an example[https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> > free to improve it or suggest changes.
> > 
> > Currently, there is a problem with the termination metric though (I don’t  
> > know why yet).

---

<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:** [January 15, 2014, 5:22pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/4 "2014-01-15T17:22:29Z")

</div>

Try:

fn{a:t0p}  
print\_lvt{n:nat}(xsl: !list\_vt (a,n)):\<!ref\> void = …On Wednesday, January 15, 2014 12:20:43 PM UTC-5, gmhwxi wrote:

> This is because the type you assigned to print\_lvt is not strong enough.  
> What happens if print\_lvt actually increase the length of its argument?  
> You have  
> to say that the type-checker is doing its work very diligently 🙂
> 
> My suggestion: please skip termination-checking.
> 
> On Wednesday, January 15, 2014 12:03:22 PM UTC-5, Brandon Barker wrote:
> 
> > That is good to know about (anything with a $ seems to be really handy).
> > 
> > I was trying to avoid using cloref1 or \<1\> cause I get:  
> > error(3): the effects [exn, ntm] are disallowed
> > 
> > and it seemed easier to worry about 1 eff rather than 3.
> > 
> > Unfortunately, even with effmask\_all, the termination metric problem  
> > still occurs if the print\_lvt statement is uncommented.[https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab](https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab)
> > 
> > On Wednesday, January 15, 2014 10:38:32 AM UTC-5, gmhwxi wrote:
> > 
> > > you can use $effmask\_all(print(…)) to mask effects.
> > > 
> > > On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:
> > > 
> > > > There are a lot of nice library functions and succinct algorithms in  
> > > > ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> > > > in ATS2 using templates where possible.  
> > > > It can be helpful to check one’s understanding of the ATS1 code by  
> > > > inspection and modification before attempting to port to ATS2.
> > > > 
> > > > One alternative is to use version control, but others may prefer to  
> > > > copy and paste code into a single file with included tests. This may  
> > > > involve copy from several files though.  
> > > > I’ve put an example[https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> > > > free to improve it or suggest changes.
> > > > 
> > > > Currently, there is a problem with the termination metric though (I  
> > > > don’t know why yet).

---

<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:** [January 15, 2014, 5:20pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/5 "2014-01-15T17:20:43Z")

</div>

This is because the type you assigned to print\_lvt is not strong enough.  
What happens if print\_lvt actually increase the length of its argument? You  
have  
to say that the type-checker is doing its work very diligently 🙂

My suggestion: please skip termination-checking.On Wednesday, January 15, 2014 12:03:22 PM UTC-5, Brandon Barker wrote:

> That is good to know about (anything with a $ seems to be really handy).
> 
> I was trying to avoid using cloref1 or \<1\> cause I get:  
> error(3): the effects [exn, ntm] are disallowed
> 
> and it seemed easier to worry about 1 eff rather than 3.
> 
> Unfortunately, even with effmask\_all, the termination metric problem still  
> occurs if the print\_lvt statement is uncommented.[https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab](https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab)
> 
> On Wednesday, January 15, 2014 10:38:32 AM UTC-5, gmhwxi wrote:
> 
> > you can use $effmask\_all(print(…)) to mask effects.
> > 
> > On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:
> > 
> > > There are a lot of nice library functions and succinct algorithms in  
> > > ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> > > in ATS2 using templates where possible.  
> > > It can be helpful to check one’s understanding of the ATS1 code by  
> > > inspection and modification before attempting to port to ATS2.
> > > 
> > > One alternative is to use version control, but others may prefer to copy  
> > > and paste code into a single file with included tests. This may involve  
> > > copy from several files though.  
> > > I’ve put an example[https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> > > free to improve it or suggest changes.
> > > 
> > > Currently, there is a problem with the termination metric though (I  
> > > don’t know why yet).

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [January 15, 2014, 5:40pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/6 "2014-01-15T17:40:31Z")

</div>

That does it. That makes sense, just like switching between string and  
string(n) can give trouble.On Wednesday, January 15, 2014 12:22:29 PM UTC-5, gmhwxi wrote:

> Try:
> 
> fn{a:t0p}  
> print\_lvt{n:nat}(xsl: !list\_vt (a,n)):\<!ref\> void = …
> 
> On Wednesday, January 15, 2014 12:20:43 PM UTC-5, gmhwxi wrote:
> 
> > This is because the type you assigned to print\_lvt is not strong enough.  
> > What happens if print\_lvt actually increase the length of its argument?  
> > You have  
> > to say that the type-checker is doing its work very diligently 🙂
> > 
> > My suggestion: please skip termination-checking.
> > 
> > On Wednesday, January 15, 2014 12:03:22 PM UTC-5, Brandon Barker wrote:
> > 
> > > That is good to know about (anything with a $ seems to be really handy).
> > > 
> > > I was trying to avoid using cloref1 or \<1\> cause I get:  
> > > error(3): the effects [exn, ntm] are disallowed
> > > 
> > > and it seemed easier to worry about 1 eff rather than 3.
> > > 
> > > Unfortunately, even with effmask\_all, the termination metric problem  
> > > still occurs if the print\_lvt statement is uncommented.[https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab](https://gist.github.com/bbarker/d068e38107e4b801b7c5/33847f180cdf8ab36c27d9b05d2ef6bca1191aab)
> > > 
> > > On Wednesday, January 15, 2014 10:38:32 AM UTC-5, gmhwxi wrote:
> > > 
> > > > you can use $effmask\_all(print(…)) to mask effects.
> > > > 
> > > > On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:
> > > > 
> > > > > There are a lot of nice library functions and succinct algorithms in  
> > > > > ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> > > > > in ATS2 using templates where possible.  
> > > > > It can be helpful to check one’s understanding of the ATS1 code by  
> > > > > inspection and modification before attempting to port to ATS2.
> > > > > 
> > > > > One alternative is to use version control, but others may prefer to  
> > > > > copy and paste code into a single file with included tests. This may  
> > > > > involve copy from several files though.  
> > > > > I’ve put an example[https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> > > > > free to improve it or suggest changes.
> > > > > 
> > > > > Currently, there is a problem with the termination metric though (I  
> > > > > don’t know why yet).

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [January 15, 2014, 3:35pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/7 "2014-01-15T15:35:35Z")

</div>

changing clo to “cloref” fixes this, but when the print\_lvt statement is  
uncommented, we are back to the termination metric issue:  
/home/brand\_000/linset\_union/d068e38107e4b801b7c5/linset\_ats1libtest.dats:  
2218(line=89, offs=20) – 2222(line=89, offs=24): error(3): unsolved  
constraint for termination metric being decreasing: C3STRprop(metric\_dec;  
S2Emetlt(S2Eapp(S2Ecst(+); S2EVar(2573), S2EVar(2574)), S2Eapp(S2Ecst(+);  
S2Evar(n1(5415)), S2Evar(n2(5416)))))On Wednesday, January 15, 2014 10:28:27 AM UTC-5, Brandon Barker wrote:

> In the current version where I try to combine clo and !ref[https://gist.github.com/bbarker/d068e38107e4b801b7c5/c3fd0f9d2a34557a2335e5e62d18a2332a88c027](https://gist.github.com/bbarker/d068e38107e4b801b7c5/c3fd0f9d2a34557a2335e5e62d18a2332a88c027),  
> I get a gcc error, which indicates I’m probably not doing things in the  
> usual or correct way:
> 
> $ atscc linset\_ats1libtest.dats  
> /home/brand\_000/ats-lang-anairiats-0.2.11/bin/atsopt --output  
> linset\_ats1libtest\_dats.c --dynamic linset\_ats1libtest.dats  
> gcc -I/home/brand\_000/ats-lang-anairiats-0.2.11/  
> -I/home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/runtime/  
> -L/home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/lib/  
> /home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/runtime/ats\_prelude.c  
> linset\_ats1libtest\_dats.c -lats  
> linset\_ats1libtest\_dats.c: In function ‘loop\_8’:  
> linset\_ats1libtest\_dats.c:541:15: error: cannot convert to a pointer type  
> /\* tmp36 = _/ ((ats\_void\_type(_)(ats\_clo\_ptr\_type, ats\_ptr\_type,  
> ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, tmp35, arg1,  
> tmp30) ;  
> ^  
> linset\_ats1libtest\_dats.c:541:15: error: incompatible type for argument 1  
> of ‘(ats\_void\_type (\*)(struct ats\_clo\_type \*, void \*, void _, void  
> ))0u-\>closure\_fun’  
> linset\_ats1libtest\_dats.c:541:15: note: expected ‘ats\_clo\_ptr\_type’ but  
> argument is of type ‘ats\_clo\_type’  
> linset\_ats1libtest\_dats.c:547:15: error: cannot convert to a pointer type  
> / tmp39 = / ((ats\_void\_type()(ats\_clo\_ptr\_type, ats\_ptr\_type,  
> ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, arg0, tmp38,  
> tmp32) ;  
> ^  
> linset\_ats1libtest\_dats.c:547:15: error: incompatible type for argument 1  
> of ‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void _, void  
> ))0u-\>closure\_fun’  
> linset\_ats1libtest\_dats.c:547:15: note: expected ‘ats\_clo\_ptr\_type’ but  
> argument is of type ‘ats\_clo\_type’  
> linset\_ats1libtest\_dats.c:553:15: error: cannot convert to a pointer type  
> / tmp42 = / ((ats\_void\_type()(ats\_clo\_ptr\_type, ats\_ptr\_type,  
> ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, tmp40, tmp41,  
> tmp30) ;  
> ^  
> linset\_ats1libtest\_dats.c:553:15: error: incompatible type for argument 1  
> of ‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void \*, void  
> _))0u-\>closure\_fun’  
> linset\_ats1libtest\_dats.c:553:15: note: expected ‘ats\_clo\_ptr\_type’ but  
> argument is of type ‘ats\_clo\_type’  
> linset\_ats1libtest\_dats.c: In function  
> ‘my\_linset\_union\_02003\_ats\_int\_type’:  
> linset\_ats1libtest\_dats.c:611:15: warning: passing argument 1 of  
> ‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void \*, void \*))((struct  
> ats\_clo\_type _)ptrof\_error(loop\_8\_closure\_error()))-\>closure\_fun’ makes  
> pointer from integer without a cast [enabled by default]  
> /_ tmp44 = _/ ((ats\_void\_type(_)(ats\_clo\_ptr\_type, ats\_ptr\_type,  
> ats\_ptr\_type,  
> ats\_ref\_type))(ats\_closure\_fun(ptrof\_error(loop\_8\_closure\_error ()))))  
> (ptrof\_error(loop\_8\_closure\_error ()), arg0, arg1, (&tmp43)) ;  
> ^  
> linset\_ats1libtest\_dats.c:611:15: note: expected ‘ats\_clo\_ptr\_type’ but  
> argument is of type ‘int’  
> Exit: [gcc] failed.
> 
> On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:
> 
> > There are a lot of nice library functions and succinct algorithms in  
> > ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> > in ATS2 using templates where possible.  
> > It can be helpful to check one’s understanding of the ATS1 code by  
> > inspection and modification before attempting to port to ATS2.
> > 
> > One alternative is to use version control, but others may prefer to copy  
> > and paste code into a single file with included tests. This may involve  
> > copy from several files though.  
> > I’ve put an example[https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> > free to improve it or suggest changes.
> > 
> > Currently, there is a problem with the termination metric though (I don’t  
> > know why yet).

---

<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:** [January 15, 2014, 3:38pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/8 "2014-01-15T15:38:32Z")

</div>

you can use $effmask\_all(print(…)) to mask effects.On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:

> There are a lot of nice library functions and succinct algorithms in  
> ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> in ATS2 using templates where possible.  
> It can be helpful to check one’s understanding of the ATS1 code by  
> inspection and modification before attempting to port to ATS2.
> 
> One alternative is to use version control, but others may prefer to copy  
> and paste code into a single file with included tests. This may involve  
> copy from several files though.  
> I’ve put an example [https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> free to improve it or suggest changes.
> 
> Currently, there is a problem with the termination metric though (I don’t  
> know why yet).

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [January 15, 2014, 3:28pm UTC](https://discourse.ats-lang.org/t/helping-to-flesh-out-atslib-in-ats2/243/9 "2014-01-15T15:28:27Z")

</div>

In the current version where I try to combine clo and !ref[https://gist.github.com/bbarker/d068e38107e4b801b7c5/c3fd0f9d2a34557a2335e5e62d18a2332a88c027](https://gist.github.com/bbarker/d068e38107e4b801b7c5/c3fd0f9d2a34557a2335e5e62d18a2332a88c027),  
I get a gcc error, which indicates I’m probably not doing things in the  
usual or correct way:

$ atscc linset\_ats1libtest.dats  
/home/brand\_000/ats-lang-anairiats-0.2.11/bin/atsopt --output  
linset\_ats1libtest\_dats.c --dynamic linset\_ats1libtest.dats  
gcc -I/home/brand\_000/ats-lang-anairiats-0.2.11/  
-I/home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/runtime/  
-L/home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/lib/  
/home/brand\_000/ats-lang-anairiats-0.2.11/ccomp/runtime/ats\_prelude.c  
linset\_ats1libtest\_dats.c -lats  
linset\_ats1libtest\_dats.c: In function ‘loop\_8’:  
linset\_ats1libtest\_dats.c:541:15: error: cannot convert to a pointer type  
/\* tmp36 = _/ ((ats\_void\_type(_)(ats\_clo\_ptr\_type, ats\_ptr\_type,  
ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, tmp35, arg1,  
tmp30) ;  
^  
linset\_ats1libtest\_dats.c:541:15: error: incompatible type for argument 1  
of ‘(ats\_void\_type (\*)(struct ats\_clo\_type \*, void \*, void _, void  
 ))0u-\>closure\_fun’  
linset\_ats1libtest\_dats.c:541:15: note: expected ‘ats\_clo\_ptr\_type’ but  
argument is of type ‘ats\_clo\_type’  
linset\_ats1libtest\_dats.c:547:15: error: cannot convert to a pointer type  
/ tmp39 = / ((ats\_void\_type()(ats\_clo\_ptr\_type, ats\_ptr\_type,  
ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, arg0, tmp38,  
tmp32) ;  
^  
linset\_ats1libtest\_dats.c:547:15: error: incompatible type for argument 1  
of ‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void _, void  
 ))0u-\>closure\_fun’  
linset\_ats1libtest\_dats.c:547:15: note: expected ‘ats\_clo\_ptr\_type’ but  
argument is of type ‘ats\_clo\_type’  
linset\_ats1libtest\_dats.c:553:15: error: cannot convert to a pointer type  
/ tmp42 = / ((ats\_void\_type()(ats\_clo\_ptr\_type, ats\_ptr\_type,  
ats\_ptr\_type, ats\_ref\_type))(ats\_closure\_fun(env1))) (env1, tmp40, tmp41,  
tmp30) ;  
^  
linset\_ats1libtest\_dats.c:553:15: error: incompatible type for argument 1  
of ‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void \*, void  
_))0u-\>closure\_fun’  
linset\_ats1libtest\_dats.c:553:15: note: expected ‘ats\_clo\_ptr\_type’ but  
argument is of type ‘ats\_clo\_type’  
linset\_ats1libtest\_dats.c: In function ‘my\_linset\_union\_02003\_ats\_int\_type’:  
linset\_ats1libtest\_dats.c:611:15: warning: passing argument 1 of  
‘(ats\_void\_type (_)(struct ats\_clo\_type \*, void \*, void \*, void \*))((struct  
ats\_clo\_type _)ptrof\_error(loop\_8\_closure\_error()))-\>closure\_fun’ makes  
pointer from integer without a cast [enabled by default]  
/_ tmp44 = _/ ((ats\_void\_type(_)(ats\_clo\_ptr\_type, ats\_ptr\_type,  
ats\_ptr\_type,  
ats\_ref\_type))(ats\_closure\_fun(ptrof\_error(loop\_8\_closure\_error ()))))  
(ptrof\_error(loop\_8\_closure\_error ()), arg0, arg1, (&tmp43)) ;  
^  
linset\_ats1libtest\_dats.c:611:15: note: expected ‘ats\_clo\_ptr\_type’ but  
argument is of type ‘int’  
Exit: [gcc] failed.On Tuesday, January 14, 2014 8:25:41 PM UTC-5, Brandon Barker wrote:

> There are a lot of nice library functions and succinct algorithms in  
> ATS1’s ATSLIB, while at the same time, many of these seem to be implemented  
> in ATS2 using templates where possible.  
> It can be helpful to check one’s understanding of the ATS1 code by  
> inspection and modification before attempting to port to ATS2.
> 
> One alternative is to use version control, but others may prefer to copy  
> and paste code into a single file with included tests. This may involve  
> copy from several files though.  
> I’ve put an example [https://gist.github.com/bbarker/d068e38107e4b801b7c5](https://gist.github.com/bbarker/d068e38107e4b801b7c5)of this up as a git gist for linset\_union (copied to my\_linset\_union); feel  
> free to improve it or suggest changes.
> 
> Currently, there is a problem with the termination metric though (I don’t  
> know why yet).
