Re: Template Issue

2021-11-29 Thread d4v3y_5c0n3s
First, you were right, '-DATS_MEMALLOC_LIBC' fixed the code on my end so 
that it compiles fine.

Second, it never even occurred to me that Javascript may not use the "main" 
function pattern used by C-family languages.  With this in mind, it now 
makes perfect sense as to why my code didn't work.

Thanks for the help.
On Monday, November 29, 2021 at 12:15:59 PM UTC-5 gmhwxi wrote:

> If you try to compile to JS, then you cannot have 'main0' in your code.
> For instance, the following code worked when I tried:
>
>
>
>
>
>
>
> *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} maybe_nah 
> () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) = YAH(x)*
>
> *val () = let*
>
>
>
>
>
>
> *var m1 = maybe_nah()var m2 = maybe_yah(6)val-~NAH() 
> = m1val-~YAH(int) = m2inend*
> On Mon, Nov 29, 2021 at 11:03 AM d4v3y_5c0n3s  wrote:
>
>> You need to select the "Patsopt2js" button when using Try-ATS-on-line to 
>> get the error I posted.  I'll test using my local ATS installation to 
>> determine whether this is only on the JS version of ATS or not.
>> On Monday, November 29, 2021 at 10:23:56 AM UTC-5 gmhwxi wrote:
>>
>>> Is there a way for me to generate the error you are referring to?
>>> The above code works fine on my end.
>>>
>>> --Hongwei
>>>
>>>
>>> On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:
>>>
 I think I've been able to break down a problem I've been having with 
 ATS' templates into a simple example provided below.  The following code 
 type-checks, and can easily tested using Try-ATS-on-line.














 *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} 
 maybe_nah () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) 
 = 
 YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 = 
 maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*

 Running the above sample produces the following error:
 ParsingErrors:
 /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454, 
 offs=4): error(parsing): the keyword [EOF] is needed.
 exit(ATS): uncaught exception at run-time:

 /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)

 My question is, why is this simple example failing, and how should I 
 fix it?  I know the problem is related to metaprogramming in some way, but 
 I don't understand the low-level details enough to get why this isn't 
 working.  Please let me know if you have any further questions.

 -- 
 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 view this discussion on the web visit 
 https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/d58686a2-e910-4ab4-bfe3-e33fd1bc312dn%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/3151c499-3940-470a-8c9d-1bc2abe8e576n%40googlegroups.com.


Re: Template Issue

2021-11-29 Thread Hongwei Xi
If you try to compile to JS, then you cannot have 'main0' in your code.
For instance, the following code worked when I tried:







*datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} maybe_nah
() : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) = YAH(x)*







*val () = letvar m1 = maybe_nah()var m2 = maybe_yah(6)
val-~NAH() = m1val-~YAH(int) = m2inend*

On Mon, Nov 29, 2021 at 11:03 AM d4v3y_5c0n3s  wrote:

> You need to select the "Patsopt2js" button when using Try-ATS-on-line to
> get the error I posted.  I'll test using my local ATS installation to
> determine whether this is only on the JS version of ATS or not.
> On Monday, November 29, 2021 at 10:23:56 AM UTC-5 gmhwxi wrote:
>
>> Is there a way for me to generate the error you are referring to?
>> The above code works fine on my end.
>>
>> --Hongwei
>>
>>
>> On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:
>>
>>> I think I've been able to break down a problem I've been having with
>>> ATS' templates into a simple example provided below.  The following code
>>> type-checks, and can easily tested using Try-ATS-on-line.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype}
>>> maybe_nah () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) =
>>> YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 =
>>> maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*
>>>
>>> Running the above sample produces the following error:
>>> ParsingErrors:
>>> /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454,
>>> offs=4): error(parsing): the keyword [EOF] is needed.
>>> exit(ATS): uncaught exception at run-time:
>>>
>>> /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)
>>>
>>> My question is, why is this simple example failing, and how should I fix
>>> it?  I know the problem is related to metaprogramming in some way, but I
>>> don't understand the low-level details enough to get why this isn't
>>> working.  Please let me know if you have any further questions.
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/d58686a2-e910-4ab4-bfe3-e33fd1bc312dn%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpRoz_wLBqkMR0Q9CAuCwk4EPHFbPPxFK4R6uQEBZn8-w%40mail.gmail.com.


Re: Template Issue

2021-11-29 Thread Hongwei Xi
You need the flag '-DATS_MEMALLOC_LIBC'.


On Mon, Nov 29, 2021 at 12:00 PM d4v3y_5c0n3s  wrote:

> I tried to compile the above snippet on my local machine, and got the
> following error:
> /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld:
> /tmp/ccVVVRVe.o:metap_test_dat:(.text+0x12a): undefined reference to
> `atsruntime_mfree_undef'
> /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld:
> /tmp/ccVVVRVe.o:metap_test_dat:(.text+0x160): undefined reference to
> `atsruntime_malloc_undef'
> collect2: error: ld returned 1 exit status
>
> I have no idea what it means or what caused it.
>
> On Monday, November 29, 2021 at 11:03:29 AM UTC-5 d4v3y_5c0n3s wrote:
>
>> You need to select the "Patsopt2js" button when using Try-ATS-on-line to
>> get the error I posted.  I'll test using my local ATS installation to
>> determine whether this is only on the JS version of ATS or not.
>> On Monday, November 29, 2021 at 10:23:56 AM UTC-5 gmhwxi wrote:
>>
>>> Is there a way for me to generate the error you are referring to?
>>> The above code works fine on my end.
>>>
>>> --Hongwei
>>>
>>>
>>> On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:
>>>
 I think I've been able to break down a problem I've been having with
 ATS' templates into a simple example provided below.  The following code
 type-checks, and can easily tested using Try-ATS-on-line.














 *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype}
 maybe_nah () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) =
 YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 =
 maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*

 Running the above sample produces the following error:
 ParsingErrors:
 /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454,
 offs=4): error(parsing): the keyword [EOF] is needed.
 exit(ATS): uncaught exception at run-time:

 /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)

 My question is, why is this simple example failing, and how should I
 fix it?  I know the problem is related to metaprogramming in some way, but
 I don't understand the low-level details enough to get why this isn't
 working.  Please let me know if you have any further questions.

 --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/386c6ed6-d6f1-491d-ac67-d8b39a511439n%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqRyVQXM5SRLCyh6AapzeoPZ%2BxFetVBj2NiReyia2nzsw%40mail.gmail.com.


Re: Template Issue

2021-11-29 Thread d4v3y_5c0n3s
I tried to compile the above snippet on my local machine, and got the 
following error:
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: 
/tmp/ccVVVRVe.o:metap_test_dat:(.text+0x12a): undefined reference to 
`atsruntime_mfree_undef'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: 
/tmp/ccVVVRVe.o:metap_test_dat:(.text+0x160): undefined reference to 
`atsruntime_malloc_undef'
collect2: error: ld returned 1 exit status

I have no idea what it means or what caused it.

On Monday, November 29, 2021 at 11:03:29 AM UTC-5 d4v3y_5c0n3s wrote:

> You need to select the "Patsopt2js" button when using Try-ATS-on-line to 
> get the error I posted.  I'll test using my local ATS installation to 
> determine whether this is only on the JS version of ATS or not.
> On Monday, November 29, 2021 at 10:23:56 AM UTC-5 gmhwxi wrote:
>
>> Is there a way for me to generate the error you are referring to?
>> The above code works fine on my end.
>>
>> --Hongwei
>>
>>
>> On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:
>>
>>> I think I've been able to break down a problem I've been having with 
>>> ATS' templates into a simple example provided below.  The following code 
>>> type-checks, and can easily tested using Try-ATS-on-line.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} 
>>> maybe_nah () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) = 
>>> YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 = 
>>> maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*
>>>
>>> Running the above sample produces the following error:
>>> ParsingErrors:
>>> /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454, 
>>> offs=4): error(parsing): the keyword [EOF] is needed.
>>> exit(ATS): uncaught exception at run-time:
>>>
>>> /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)
>>>
>>> My question is, why is this simple example failing, and how should I fix 
>>> it?  I know the problem is related to metaprogramming in some way, but I 
>>> don't understand the low-level details enough to get why this isn't 
>>> working.  Please let me know if you have any further questions.
>>>
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/386c6ed6-d6f1-491d-ac67-d8b39a511439n%40googlegroups.com.


Re: Template Issue

2021-11-29 Thread d4v3y_5c0n3s
You need to select the "Patsopt2js" button when using Try-ATS-on-line to 
get the error I posted.  I'll test using my local ATS installation to 
determine whether this is only on the JS version of ATS or not.
On Monday, November 29, 2021 at 10:23:56 AM UTC-5 gmhwxi wrote:

> Is there a way for me to generate the error you are referring to?
> The above code works fine on my end.
>
> --Hongwei
>
>
> On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:
>
>> I think I've been able to break down a problem I've been having with ATS' 
>> templates into a simple example provided below.  The following code 
>> type-checks, and can easily tested using Try-ATS-on-line.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} maybe_nah 
>> () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) = 
>> YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 = 
>> maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*
>>
>> Running the above sample produces the following error:
>> ParsingErrors:
>> /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454, 
>> offs=4): error(parsing): the keyword [EOF] is needed.
>> exit(ATS): uncaught exception at run-time:
>>
>> /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)
>>
>> My question is, why is this simple example failing, and how should I fix 
>> it?  I know the problem is related to metaprogramming in some way, but I 
>> don't understand the low-level details enough to get why this isn't 
>> working.  Please let me know if you have any further questions.
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/d58686a2-e910-4ab4-bfe3-e33fd1bc312dn%40googlegroups.com.


Re: Template Issue

2021-11-29 Thread Hongwei Xi
Is there a way for me to generate the error you are referring to?
The above code works fine on my end.

--Hongwei


On Mon, Nov 29, 2021 at 10:16 AM d4v3y_5c0n3s  wrote:

> I think I've been able to break down a problem I've been having with ATS'
> templates into a simple example provided below.  The following code
> type-checks, and can easily tested using Try-ATS-on-line.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *datavtype maybe(a:vt@ype) =| NAH of ()| YAH of (a)fn{a:vt@ype} maybe_nah
> () : maybe(a) = NAH()fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) =
> YAH(x)implement main0 () = letvar m1 = maybe_nah()var m2 =
> maybe_yah(6)val-~NAH() = m1val-~YAH(int) = m2inend*
>
> Running the above sample produces the following error:
> ParsingErrors:
> /tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454,
> offs=4): error(parsing): the keyword [EOF] is needed.
> exit(ATS): uncaught exception at run-time:
>
> /var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)
>
> My question is, why is this simple example failing, and how should I fix
> it?  I know the problem is related to metaprogramming in some way, but I
> don't understand the low-level details enough to get why this isn't
> working.  Please let me know if you have any further questions.
>
> --
> 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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrFc_YHC92-itPB5X%2B0o%2B3Qm4WHtPoOa2s3mMnmXYz1pQ%40mail.gmail.com.