Re: About scientific computing with ATS and notation

2022-01-25 Thread d4v3y_5c0n3s
Hi Yann,
  I'm glad to see others showing interest in ATS :D.  I'm not very familiar 
with the sort of scientific programming that you are talking about, but 
I'll do my best to respond to your questions regardless.
  You asked whether you could use 128 bit integers, SIMD, multicore, and 
even distributed computing.  Like, holy moly man.  :D  But yea, ATS can do 
basically anything C can, with the caveat that you may need to write FFI 
code due to the small size of the ATS ecosystem.
  As for the static capabilities of ATS, this I believe to be the strongest 
quality of ATS.  Indexing into arrays/matrices is verified at compile time 
so your example should be recreate-able in ATS.  And no, ATS' type system 
doesn't require you to constantly cast to verify the range of an integer, 
but it will force you write your code in such a way that the system knows 
without a doubt that the integer is not out of range.  It's hard to 
explain, but if you are interested I'd recommend working through the Intro 
to ATS book in the documentation on the website.
  I'm not involved with the development of ATS3, so gmhwxi would know more 
about how much it will change.  I'd recommend reading previous posts about 
ATS3 to find out more.
Good luck.

On Sunday, January 23, 2022 at 12:46:12 PM UTC-5 Yann Le Du wrote:

> Dear ATSites,
>
> First, impressed by the power of ATS which unfortunately for me is still 
> inaccessible even after spending the typical time I spend overviewing other 
> languages. For sure, I've listened to many people saying how hard it was, 
> so that didn't help ;-) Maybe they want to keep ATS for themselves and 
> frighten away potential new users ?
>
> I'm a physicist, cosmologist, currently working on setting up a project 
> involving image reconstruction, around what the Chebfun matlab toolbox 
> implements. Now, I've been looking at Dex, he new google research language, 
> because that's typically what I need,for exactly the same reason the 
> designers made Dex (escape Matlab and go for more than its clone on juice, 
> Julia) but it looks very experimental and doesn't really have all I need, 
> especially interfacing with C.
>
> So first, would I be able to massage ATS into allowing some nice syntax, I 
> mean can I code a library (using whatever tools I totally don't understand 
> today) that would allow me to write 
>
> `for i,j: C.i.j = A.i.k * B.k.j`
>
> In a very similar way to Dex (who has ranged integer type for the 
> indices), i.e. which would be interpreted as :
>
> ```
> for i in rows range of A:
>   for j in colums range of B:
> for k in cols of A == rows of B:
>   C[i,j] = A[i,k] * B[k,j]
> ```
>
> or whatever equivalent in ATS.
>
> You will notice that it loops implicitly on k (Einstein summation), thus 
> without me specifying k, and all the indices getting checked like in Dex at 
> compile time, with inference wherever needed. This means I want to be able 
> to write M.2.3 = 25 (meaning M[2,3]=5) without casting overhead like in Dex 
> (they have to cast from integers to ranged ordinals if I remember).
>
> I would also need support for 128 bit integers and all for cryptographic 
> uses, the possibility of defining
>
> foo(m `Matrix[12 rows, any u32 in [0,23] columns, any float type for the 
> elements, unknown variance]`)
>
> and then call foo with `foo(b)` and b is checked to fit the type declared 
> for foo's arguments, so it wold tell me if I try to put in a matrix with 
> too many rows, but accept a matrix with 12 rows and 21 columns filled with 
> f32, the possibility of defining a set of accepted types, including 
> constants, and check if what I use belongs to that set, abstractions like 
> OO to better contain the math abstractions we manipulate.
>
> Also, the possibility to implement the right structures for SIMD and all 
> that, SOA, etc. This organizing my memory as I want, perhaps not from the 
> start, but as the project progresses.
>
> The possibility of multicores, and distributed computing.
>
> Proving that some functions are right.
>
> And last but not least, how much will I have to [un|re]learn when ATS3 is 
> released ?
>
> And maybe other questions will follow if the above receives positive 
> answers...
>
> By the way, why no Discord channel ? It's so helpful for a community.
>
> It's a big pile of questions, I just want to know if learning ATS could 
> make those features possible. My other path is to go to Rust and hope I can 
> massage the macros to handle my syntax, but Rust doesn't have true range 
> types for the tensor indices I want to use, although some crate imitates 
> them, and ATS looks much more powerful to me.
>
> That's it, I hope ATS can do all that.
>
> Best,
>
> Yann
>

-- 
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 

Re: general questions about ats postiats and upcoming xanadu compatibility

2022-01-25 Thread d4v3y_5c0n3s
I'll try to answer your questions to the best of my ability.

   1. ATS Postiats (also known as ATS2) does not currently support MSVC, 
   and likely never will since ATS Xanadu (a.k.a. ATS3) is the main focus of 
   the lead developer.
   2. I don't know what C standard ATS compiles to, but it's probably safe 
   to assume it compiles to C99 unless there is evidence to the contrary.
   3. In ATS2 you have full access to C's pre-processor, and can use it 
   just like how you would when programming in C.
   4. I know you can use pthreads in ATS, there are some examples of this 
   in the ATS Postiats.  Assuming win32-threads are accessible through a C 
   API, then ATS can use it via FFI.

If you are interested in learning to use ATS, I'd reccommend checking out 
the documentation available on the ATS website 
 and the wiki page for ATS2 
.  And don't be afraid to 
post addition questions. :D

On Friday, January 21, 2022 at 11:30:43 AM UTC-5 saif.ras...@gmail.com 
wrote:

> correction for 4 b: if not 4 a then can i jam win32-thread code into "<% 
> %>" delims
>
> On Friday, January 21, 2022 at 9:28:32 PM UTC+5 saif.ras...@gmail.com 
> wrote:
>
>> hi everyone, sorry for noob questions
>> 1. will there be support added for msvc?
>> 2. does ats code compile to c89 and/or c99?
>> 3. does it support  pre-processor?
>> 4.  a) if it does would you be able to use win32-threads aswell as 
>> pthreads?
>>   b) if not can i jam win32-thread code into the "<% %>" delimiters
>> thanks.
>>
>

-- 
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/46b1fdad-9c32-4a85-8d1f-510db429bb49n%40googlegroups.com.


Re: Help with Templates, cannot find missing implementation somewhere...

2022-01-01 Thread d4v3y_5c0n3s
That seems to have fixed my issue, thanks.  :)

On Thursday, December 30, 2021 at 9:28:57 PM UTC-5 gmhwxi wrote:

> Or you could supply a template parameter (bucket(a) in this case) to
> arrayptr_freelin:
>
> implmnt{a} dict_delete_lin ( d ) = let
>   implmnt array_uninitize$clear (i, x) = 
> bucket_delete_recursive(x)
> in
>   arrayptr_freelin(d.buckets, size_of_int(d.size))
> end
> On Thursday, December 30, 2021 at 9:00:48 PM UTC-5 gmhwxi wrote:
>
>> Just need to replace bucket(a) with BUCKET(a) as is shown below:
>>
>>   implmnt array_uninitize$clear (i, x) = 
>> bucket_delete_recursive(x)
>>
>> On Thursday, December 30, 2021 at 6:07:31 PM UTC-5 d4v3y_5c0n3s wrote:
>>
>>> Here are the files, with some of the functions that are never used in 
>>> the example removed.
>>> The code was compiled with:  *patscc -c -DATS_MEMALLOC_LIBC dict.dats*
>>> | | |
>>> (*
>>> ###  dict.sats  ###
>>>
>>>
>>> *)
>>>
>>> #include "share/atspre_staload.hats"
>>>
>>> (*  buckets (aka linked lists)  *)
>>> absvtype bucket (a:vt@ype) = ptr
>>>
>>> fn{a:vt@ype} bucket_new ( string, a ) : bucket(a)
>>>
>>> fn{a:vt@ype} bucket_map ( !bucket(a) ) : void
>>> fn{a:vt@ype} bucket_filter_map ( b: !bucket(a) ) : void
>>>
>>>
>>> fn{a:vt@ype} bucket_item$delete ( x: a ): void
>>> fn{a:vt@ype} bucket_item$map ( x: &a ): void
>>> fn{a:vt@ype} bucket_item$filter ( x: !a ): bool
>>> fn{a:vt@ype} bucket_item$to_string ( x: !a ): string
>>>
>>>
>>> fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
>>>
>>> fn{a:vt@ype} bucket_print ( b: !bucket(a) ) : void
>>>
>>> (*  dictionaries  *)
>>>
>>> sortdef dsz = {s:int | s > 0}
>>> absvt@ype dict (a:vt@ype, n:int) = @{size=int,buckets=ptr}
>>>
>>>
>>> fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
>>> fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
>>> fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
>>> fn{a:vt@ype} dict_delete_fun {s:dsz} ( d: dict(a, s), (a) -> void ) : 
>>> void
>>> | | |
>>> (*
>>> ###  dict.dats  ###
>>>
>>>
>>> *)
>>>
>>> #include "share/atspre_staload.hats"
>>>
>>> staload "./dict.sats"
>>>
>>> fn hash {n:int | n>0}{s:int | s>0}
>>> ( s: string(s), size: int(n) ) : [o:int | o >= 0; o < n] int o = let
>>> fun hash_num {i:nat | i <= s}
>>> ( i: int i, h: int, str_sz: int(s) ) : int =
>>> if i < str_sz then let
>>> val c_at_i = string_get_at_gint(s, i)
>>> in
>>> hash_num(i+1, h * 101 + g0int_of_char(c_at_i), 
>>> str_sz)
>>> end else h
>>> in
>>> g1int_nmod(abs(g1ofg0(hash_num(0, 0, sz2i(strlen(s), size)
>>> end
>>>
>>> local
>>>
>>> datavtype BUCKET (a:vt@ype) =
>>> | bucket_empty of ()
>>> | bucket_filled of (Strptr1, a, BUCKET(a))
>>>
>>> assume bucket(a:vt@ype) = BUCKET(a)
>>> assume dict(a:vt@ype, n:int) = @{
>>>   size=int n,
>>>   buckets=arrayptr(bucket(a), n)
>>> }
>>>
>>> extern fn{a:vt@ype} bucket_operate ( !bucket(a) ) : void
>>>
>>>
>>> in
>>>
>>> implement{a} dict_new {s} ( size ) = let
>>> val size_st = size_of_int(size)
>>> val bucket_arr = arrayptr_make_uninitized(size_st)
>>> implmnt array_initize$init (i, x) = x := bucket_empty()
>>> val () = arrayptr_initize(bucket_arr, size_st)
>>> in
>>> @{size=size, buckets=bucket_arr}:dict(a, s)
>>> end
>>>
>>> implmnt{a} dict_delete ( d ) = let
>>>   implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
>>> in
>>>   dict_delete_lin(d)
>>> end
>>>
>>> implmnt{a} bucket_delete_recursive ( b ) =
>>> case+ b of
>>> | ~bucket_empty() => ()
>>> | ~bucket_filled(str, x, next_bucket) => let
>>> val () = strptr_free(str)
>>> val () = bucket_item$delete(x)
>>> in
>>> bucket_delete_recursive(next_bucket)
>>> end
>>>
>>> implmnt{a} dict_delete_lin ( d ) = let
>>>   implmnt array_uninitize$cle

Re: Help with Templates, cannot find missing implementation somewhere...

2021-12-30 Thread d4v3y_5c0n3s
Here are the files, with some of the functions that are never used in the 
example removed.
The code was compiled with:  *patscc -c -DATS_MEMALLOC_LIBC dict.dats*
| | |
(*
###  dict.sats  ###


*)

#include "share/atspre_staload.hats"

(*  buckets (aka linked lists)  *)
absvtype bucket (a:vt@ype) = ptr

fn{a:vt@ype} bucket_new ( string, a ) : bucket(a)

fn{a:vt@ype} bucket_map ( !bucket(a) ) : void
fn{a:vt@ype} bucket_filter_map ( b: !bucket(a) ) : void

fn{a:vt@ype} bucket_item$delete ( x: a ): void
fn{a:vt@ype} bucket_item$map ( x: &a ): void
fn{a:vt@ype} bucket_item$filter ( x: !a ): bool
fn{a:vt@ype} bucket_item$to_string ( x: !a ): string

fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void

fn{a:vt@ype} bucket_print ( b: !bucket(a) ) : void

(*  dictionaries  *)
sortdef dsz = {s:int | s > 0}
absvt@ype dict (a:vt@ype, n:int) = @{size=int,buckets=ptr}

fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
fn{a:vt@ype} dict_delete_fun {s:dsz} ( d: dict(a, s), (a) -> void ) : void
| | |
(*
###  dict.dats  ###


*)

#include "share/atspre_staload.hats"

staload "./dict.sats"

fn hash {n:int | n>0}{s:int | s>0}
( s: string(s), size: int(n) ) : [o:int | o >= 0; o < n] int o = let
fun hash_num {i:nat | i <= s}
( i: int i, h: int, str_sz: int(s) ) : int =
if i < str_sz then let
val c_at_i = string_get_at_gint(s, i)
in
hash_num(i+1, h * 101 + g0int_of_char(c_at_i), 
str_sz)
end else h
in
g1int_nmod(abs(g1ofg0(hash_num(0, 0, sz2i(strlen(s), size)
end

local
datavtype BUCKET (a:vt@ype) =
| bucket_empty of ()
| bucket_filled of (Strptr1, a, BUCKET(a))

assume bucket(a:vt@ype) = BUCKET(a)
assume dict(a:vt@ype, n:int) = @{
  size=int n,
  buckets=arrayptr(bucket(a), n)
}

extern fn{a:vt@ype} bucket_operate ( !bucket(a) ) : void

in

implement{a} dict_new {s} ( size ) = let
val size_st = size_of_int(size)
val bucket_arr = arrayptr_make_uninitized(size_st)
implmnt array_initize$init (i, x) = x := bucket_empty()
val () = arrayptr_initize(bucket_arr, size_st)
in
@{size=size, buckets=bucket_arr}:dict(a, s)
end

implmnt{a} dict_delete ( d ) = let
  implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
in
  dict_delete_lin(d)
end

implmnt{a} bucket_delete_recursive ( b ) =
case+ b of
| ~bucket_empty() => ()
| ~bucket_filled(str, x, next_bucket) => let
val () = strptr_free(str)
val () = bucket_item$delete(x)
in
bucket_delete_recursive(next_bucket)
end

implmnt{a} dict_delete_lin ( d ) = let
  implmnt array_uninitize$clear (i, x) = 
bucket_delete_recursive(x)
in
  arrayptr_freelin(d.buckets, size_of_int(d.size))
end

implmnt{a} dict_delete_fun ( d, dltr ) = let
  implmnt bucket_item$delete ( x ) = dltr(x)
in
  dict_delete_lin(d)
end


implmnt{a} bucket_new ( key, item ) = 
bucket_filled($UNSAFE.castvwtp0{Strptr1}(key), item, bucket_empty())

implmnt{a} bucket_map ( b ) =
  case+ b of
  | bucket_empty() => ()
  | @bucket_filled(_, x, next_bucket) => {
val () = bucket_item$map(x)
val () = bucket_map(next_bucket)
prval () = fold@(b)
  }

implmnt{a} bucket_filter_map ( b ) =
  case+ b of
  | bucket_empty() => ()
  | @bucket_filled(_, x, next_bucket) =>
  if bucket_item$filter(x) then {
  val () = bucket_item$map(x)
  val () = bucket_filter_map(next_bucket)
  prval () = fold@(b)
  }
  else {
val () = bucket_filter_map(next_bucket)
prval () = fold@(b)
  }

implmnt{a} bucket_print ( b ) =
case+ b of
| bucket_empty() => ()
| bucket_filled(str, x, next_bucket) => let
val () = print("\(")
val () = print(str)
val () = print(" : ")
val () = print( bucket_item$to_string(x) )
val () = print(")")
in
bucket_print(next_bucket)
end

end

var d = dict_new(7)
val () = dict_delete(d)
| | |
On Thursday, December 30, 2021 at 2:48:29 PM UTC-5 gmhwxi wrote:

> Where can I find your source code so that I can produce the error you are 
> referring to?
>
> --Hongwei
>
>
> On Thu, Dec 30, 2021 at 12:47 PM d4v3y_5c0n3s  wrote:
>
>> Ok, so I've been able to get the "dict" type to be abstract, but I can't 
>> seem to get "bucket" to be abstract.  I tried adding the "= ptr" part you 
>> suggested, but I'm not having any luck.  Using your solution, the code will 
>> compile, unless I test the "dict" type by calling "dict_new" & 
>> "dict_delete."  Looking at the error messages, the problem appears to be 
>> related to the "dict_delete" call, and I've provided the error below so you 
>> c

Re: Help with Templates, cannot find missing implementation somewhere...

2021-12-30 Thread d4v3y_5c0n3s
Ok, so I've been able to get the "dict" type to be abstract, but I can't 
seem to get "bucket" to be abstract.  I tried adding the "= ptr" part you 
suggested, but I'm not having any luck.  Using your solution, the code will 
compile, unless I test the "dict" type by calling "dict_new" & 
"dict_delete."  Looking at the error messages, the problem appears to be 
related to the "dict_delete" call, and I've provided the error below so you 
can see for yourself.  I know that there are a lot of details missing, so 
let me know if you'd like me to provide any more details.

Error message:
In file included from dict_dats.c:15:
dict_dats.c: In function ‘loop_95__95__1’:
dict_dats.c:6190:28: error: ‘PMVtmpltcstmat’ undeclared (first use in this 
function)
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  |^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:28: note: each undeclared identifier is reported only once 
for each function it appears in
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  |^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:46: error: ‘array_uninitize$clear’ undeclared (first use 
in this function)
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  |  ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:68: warning: implicit declaration of function ‘S2Eapp’ 
[-Wimplicit-function-declaration]
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  |   
 ^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:75: warning: implicit declaration of function ‘S2Ecst’ 
[-Wimplicit-function-declaration]
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  | 
  ^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:82: error: ‘BUCKET’ undeclared (first use in this function)
 6190 | ATSINSmove_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  | 
 ^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:89: error: expected ‘)’ before ‘;’ token
 6190 | move_void(tmp195__1, 
PMVtmpltcstmat[0](array_uninitize$clear)(arg2, 
ATSPMVrefarg1(arg0))) ;
  |   
 ~  ^

/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
dict_dats.c:6190:145: error: expected expression before ‘)’ token
 6190 | lear)(arg2, ATSPMVrefarg1(arg0))) ;
  | 
  ^

/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~

On Tuesday, December 7, 2021 at 8:08:48 AM UTC-5 d4v3y_5c0n3s wrote:

> Thanks, I tried something similar with the "dict" type, but completely 
> overlooked the "bucket" type.  I'll tes

Re: How to define linear abstract types based on records

2021-12-10 Thread d4v3y_5c0n3s
Took a closer look at my code, and turns out there was a stray "= "sta%"" 
after the "mesh_new()" function that I'd missed.  Thanks for looking at 
this, I was super confused. :)

On Friday, December 10, 2021 at 9:15:48 PM UTC-5 gmhwxi wrote:

> I could not produce the error by using the code snippet you provided.
>
> The error message in your code is likely due to the conflict between 
> nominal type equality
> (in C) and structural type equality (in ATS); postiats_tyrec_7 and 
> postiats_tyrec_15 are nominally
> different in C but they should be based on two types in ATS that are 
> structurally equal.
>
> I may be able to suggest something if I could produce the error on my side.
>
> --Hongwei
>
>
> On Fri, Dec 10, 2021 at 8:58 PM d4v3y_5c0n3s  wrote:
>
>> So, I've got the following defined in my ".sats" file:
>> absvt@ype mesh = @{v=int, t=int}
>>
>> In my ".dats" file, I've defined the following:
>> assume mesh =
>> [v,t:nat | v == t*3]
>> @{
>>   v=int v, t=int t
>> }
>> in
>> implement mesh_new (  ) = let
>> in
>>   @{
>> v=3, t=1
>>   }:mesh
>> end
>>
>>   Where "mesh_new()" is simply a function that returns a new "mesh" 
>> value.  The code I'm showing is a simplified version of my code that still 
>> exhibits the issue I was encountering (my original version had arrays, 
>> hence it being linear.)
>>   I've been getting the following cryptic error message when compiling my 
>> code:
>> !patscc -c g_engine.dats
>> g_engine_dats.c:47259:1: error: conflicting types for ‘str_043__045_’; 
>> have ‘postiats_tyrec_15()’
>> 47259 | str_043__045_()
>>   | ^
>> g_engine_dats.c:25134:1: note: previous definition of ‘str_043__045_’ 
>> with type ‘postiats_tyrec_7(atstype_float,  atstype_float,  atstype_float, 
>>  atstype_float,  atstype_float,  atstype_float,  atstype_float, 
>>  atstype_float,  atstype_float,  atstype_float,  atstype_float, 
>>  atstype_float,  atstype_float,  atstype_float,  atstype_float, 
>>  atstype_float)’ {aka ‘postiats_tyrec_7(float,  float,  float,  float, 
>>  float,  float,  float,  float,  float,  float,  float,  float,  float, 
>>  float,  float,  float)’}
>> 25134 | str_043__045_(atstkind_t0ype(atstype_float) arg0, 
>> atstkind_t0ype(atstype_float) arg1, atstkind_t0ype(atstype_float) arg2, 
>> atstkind_t0ype(atstype_float) arg3, atstkind_t0ype(atstype_float) arg4, 
>> atstkind_t0ype(atstype_float) arg5, atstkind_t0ype(atstype_float) arg6, 
>> atstkind_t0ype(atstype_float) arg7, atstkind_t0ype(atstype_float) arg8, 
>> atstkind_t0ype(atstype_float) arg9, atstkind_t0ype(atstype_float) arg10, 
>> atstkind_t0ype(atstype_float) arg11, atstkind_t0ype(atstype_float) arg12, 
>> atstkind_t0ype(atstype_float) arg13, atstkind_t0ype(atstype_float) arg14, 
>> atstkind_t0ype(atstype_float) arg15)
>>   | ^
>> !
>> My question is, what am I doing wrong?  Additionally, if you have any 
>> suggestions for where to look for an answer, that would also be welcomed.  
>> Also, feel free to request more details, since this is a simplified version 
>> of my code and I may have accidentally omitted an important detail.  I 
>> appreciate any and all help that can be provided.
>>
>> -- 
>> 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/5156ff12-80f4-4ce0-af53-9ecf04584964n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/5156ff12-80f4-4ce0-af53-9ecf04584964n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/e7afceb3-f2a5-4e9b-a170-59590ef739efn%40googlegroups.com.


How to define linear abstract types based on records

2021-12-10 Thread d4v3y_5c0n3s
So, I've got the following defined in my ".sats" file:
absvt@ype mesh = @{v=int, t=int}

In my ".dats" file, I've defined the following:
assume mesh =
[v,t:nat | v == t*3]
@{
  v=int v, t=int t
}
in
implement mesh_new (  ) = let
in
  @{
v=3, t=1
  }:mesh
end

  Where "mesh_new()" is simply a function that returns a new "mesh" value.  
The code I'm showing is a simplified version of my code that still exhibits 
the issue I was encountering (my original version had arrays, hence it 
being linear.)
  I've been getting the following cryptic error message when compiling my 
code:
!patscc -c g_engine.dats
g_engine_dats.c:47259:1: error: conflicting types for ‘str_043__045_’; have 
‘postiats_tyrec_15()’
47259 | str_043__045_()
  | ^
g_engine_dats.c:25134:1: note: previous definition of ‘str_043__045_’ with 
type ‘postiats_tyrec_7(atstype_float,  atstype_float,  atstype_float, 
 atstype_float,  atstype_float,  atstype_float,  atstype_float, 
 atstype_float,  atstype_float,  atstype_float,  atstype_float, 
 atstype_float,  atstype_float,  atstype_float,  atstype_float, 
 atstype_float)’ {aka ‘postiats_tyrec_7(float,  float,  float,  float, 
 float,  float,  float,  float,  float,  float,  float,  float,  float, 
 float,  float,  float)’}
25134 | str_043__045_(atstkind_t0ype(atstype_float) arg0, 
atstkind_t0ype(atstype_float) arg1, atstkind_t0ype(atstype_float) arg2, 
atstkind_t0ype(atstype_float) arg3, atstkind_t0ype(atstype_float) arg4, 
atstkind_t0ype(atstype_float) arg5, atstkind_t0ype(atstype_float) arg6, 
atstkind_t0ype(atstype_float) arg7, atstkind_t0ype(atstype_float) arg8, 
atstkind_t0ype(atstype_float) arg9, atstkind_t0ype(atstype_float) arg10, 
atstkind_t0ype(atstype_float) arg11, atstkind_t0ype(atstype_float) arg12, 
atstkind_t0ype(atstype_float) arg13, atstkind_t0ype(atstype_float) arg14, 
atstkind_t0ype(atstype_float) arg15)
  | ^
!
My question is, what am I doing wrong?  Additionally, if you have any 
suggestions for where to look for an answer, that would also be welcomed.  
Also, feel free to request more details, since this is a simplified version 
of my code and I may have accidentally omitted an important detail.  I 
appreciate any and all help that can be provided.

-- 
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/5156ff12-80f4-4ce0-af53-9ecf04584964n%40googlegroups.com.


Re: What is the best way to turn a file into a lazy linear stream?

2021-12-07 Thread d4v3y_5c0n3s
No worries, I understand sometimes people get busy. :)
  I eventually decided against using linear streams to process files in my 
code, at least in the way I was using it.  My code would result in being 
relatively slow, due to only retrieving one character from the file at a 
time instead of getting a large chunk of text (which is faster because we 
are making fewer requests to the system.)  Also, I found myself essentially 
needing to either rewrite regular expressions to using character streams, 
or to turn my streams into strings, which struck me as being too roundabout 
to be practical.  The only positive of using streams in the way that I 
originally planned to was that the memory footprint would be reduced, a 
tradeoff I didn't see the value of in my case.
  A better way to use streams in my case is to have a stream of strings 
rather than a stream of characters.  This way, my code will run fast while 
still benefiting from laziness by only reading the file when needed.

On Wednesday, December 1, 2021 at 12:56:16 AM UTC-5 gmhwxi wrote:

> Sorry, I didn't get a chance to read this post until now.
>
> If you use a (linear) FILEptr to create a linear stream (of chars), then 
> the FILEptr is "buried" inside
> the stream and thus it can no longer be accessed.
>
> >>My solution was to essentially combine the view for the file pointer and 
> the stream into a single type, and thus requiring both to be freed at once.
>
> To me, this seems to be the only type-safe solution (as the alternative 
> you mentioned above must make use of some unsafe features).
>
> --Hongwei
>
>
> On Sunday, October 17, 2021 at 9:14:04 AM UTC-4 d4v3y_5c0n3s wrote:
>
>> Okay, so looking back I should have provided more details in the last 
>> post, as it does not explain the issues I was encountering etc.  I posted 
>> it right before I went to bed, and that's why I rushed it.
>> Anyways, I wanted to explain how I solved my problem so that others 
>> could learn.  Basically, I was using ATS' built-in libc binding to open and 
>> read a file.  The pointer for the file was a linear type, I wasn't using 
>> the prelude's non-linear file type.  What my code did is read characters to 
>> a 'stream_vt' with the 'getc' function until it reached the end of the 
>> file.  I also planned to have other functions that would discard parts of 
>> the stream I didn't need so that I could turn the values I needed into 
>> other values (AKA, typical file-parsing stuff.)  The problem came when I 
>> needed to close the file.  Despite the use of linear types, freeing the 
>> file pointer would not prevent the stream from being access due to its 
>> laziness.  My solution was to essentially combine the view for the file 
>> pointer and the stream into a single type, and thus requiring both to be 
>> freed at once.
>> Moral of the story?  Linear types are amazing, one of the reasons I 
>> love ATS, but they are *not* a silver bullet.  They too are limited by 
>> what can be statically inferred by the compiler, and effects such as lazy 
>> values cannot be predicted by the compiler.  I hope someone was able to 
>> learn something from my post, and let me know if you have any questions.
>>
>> On Monday, October 4, 2021 at 9:17:38 PM UTC-4 d4v3y_5c0n3s wrote:
>>
>>>
>>> What the title says.  Basically, I want to use a solution that:
>>>  - does not require GC
>>>  - uses the type system to prevent the user from freeing the file before 
>>> they are done with the lazy evaluation
>>>  - is not too inconvenient for the user to use
>>> Let me know if you need an example of what I'm talking about.
>>>
>>

-- 
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/882b580c-0d25-4d5b-a2b2-f0a71567feabn%40googlegroups.com.


Re: Help with Templates, cannot find missing implementation somewhere...

2021-12-07 Thread d4v3y_5c0n3s
Thanks, I tried something similar with the "dict" type, but completely 
overlooked the "bucket" type.  I'll test this to see if it resolves the 
issue.

On Wednesday, December 1, 2021 at 12:28:15 AM UTC-5 gmhwxi wrote:

> After taking a quick look at dict.sats, I spotted the following line:
>
> absvtype bucket(a:vt@ype)
>
> which should be change to the following one:
>
> absvtype bucket(a:vt@ype) = ptr // ptr takes the compiler the size of 
> bucket
>
> The simple reason is that the compiler needs to know the size of an 
> abstract type in order to compile it to a type in C.
>
>
> On Wednesday, December 1, 2021 at 12:16:34 AM UTC-5 gmhwxi wrote:
>
>> I don't quite understand.
>> Templates in ATS2 are supposed to be working with abstract types.
>>
>> If I could try precisely what you did on your machine, then I may be able 
>> to suggest something.
>>
>>
>>
>> On Tue, Nov 30, 2021 at 8:27 PM d4v3y_5c0n3s  wrote:
>>
>>> Update 2:
>>> After investigating the prelude, I've determined that templates in ATS2 
>>> just conflict with abstract types in some instances.  For this reason, it 
>>> seems that in many parts of the prelude avoided the use of the "assume" 
>>> keyword with template-heavy code.
>>>
>>> On Tuesday, November 30, 2021 at 7:08:48 PM UTC-5 d4v3y_5c0n3s wrote:
>>>
>>>> Update:
>>>> I was able to get the code I provided above running by staloading the 
>>>> dict.dats file from the dict_test.dats file using " staload _ = 
>>>> "./dict.dats" ".  Now, my only problem is that if I make the "dict" & 
>>>> bucket types abstract, the templates stop working.
>>>>
>>>> On Tuesday, November 30, 2021 at 1:39:39 PM UTC-5 d4v3y_5c0n3s wrote:
>>>>
>>>>> You are right, including " share/atspre_staload.hats" causes the code 
>>>>> to compile.  However, I'm still having issues.  You see, the code I 
>>>>> provided I had taken from a static (.sats) and dynamic (.dats) file in 
>>>>> order to make it more presentable when asking for help.  Your fix only 
>>>>> fixes the issue in the single-file version, and when including the 
>>>>> external 
>>>>> static file it doesn't work.  Do you know what might be going wrong?  
>>>>> I'll 
>>>>> provide the (simplified) contents of each of these files below.
>>>>>
>>>>> *dict.sats*:
>>>>> #include "share/atspre_staload.hats"
>>>>>
>>>>>
>>>>> datavtype BUCKET (a:vt@ype) =
>>>>> | bucket_empty of ()
>>>>> | bucket_filled of (Strptr1, a, BUCKET(a))
>>>>>
>>>>> vtypedef bucket(a:vt@ype) = BUCKET(a)
>>>>>
>>>>> fn{a:vt@ype} bucket_item$delete ( x: a ): void
>>>>>
>>>>> fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
>>>>>
>>>>> sortdef dsz = {s:int | s > 0}
>>>>>
>>>>> vtypedef dict(a:vt@ype, n:int) =
>>>>> @{
>>>>> size=int n,
>>>>> buckets=arrayptr(bucket(a), n)
>>>>> }
>>>>>
>>>>> fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
>>>>> fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
>>>>> fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
>>>>>
>>>>>
>>>>> *dict.dats*:
>>>>> #include "share/atspre_staload.hats"
>>>>>
>>>>> staload "./dict.sats"
>>>>>
>>>>> local
>>>>> in
>>>>>
>>>>>
>>>>> implement{a} dict_new {s} ( size ) = let
>>>>> val size_st = size_of_int(size)
>>>>> val bucket_arr = arrayptr_make_uninitized(size_st)
>>>>> implmnt array_initize$init (i, x) = x := bucket_empty()
>>>>> val () = arrayptr_initize(bucket_arr, size_st)
>>>>> in
>>>>> @{size=size, buckets=bucket_arr}:dict(a, s)
>>>>> end
>>>>>
>>>>> implmnt{a} dict_delete ( d ) = let
>>>>>   implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
>>>>> in
>>>>>   dict_delete_lin(d)
>>>>> end
>>>>>
>>>>> implmnt{a} bucket_delete_recursive ( 

Re: Help with Templates, cannot find missing implementation somewhere...

2021-11-30 Thread d4v3y_5c0n3s
Update 2:
After investigating the prelude, I've determined that templates in ATS2 
just conflict with abstract types in some instances.  For this reason, it 
seems that in many parts of the prelude avoided the use of the "assume" 
keyword with template-heavy code.

On Tuesday, November 30, 2021 at 7:08:48 PM UTC-5 d4v3y_5c0n3s wrote:

> Update:
> I was able to get the code I provided above running by staloading the 
> dict.dats file from the dict_test.dats file using " staload _ = 
> "./dict.dats" ".  Now, my only problem is that if I make the "dict" & 
> bucket types abstract, the templates stop working.
>
> On Tuesday, November 30, 2021 at 1:39:39 PM UTC-5 d4v3y_5c0n3s wrote:
>
>> You are right, including " share/atspre_staload.hats" causes the code to 
>> compile.  However, I'm still having issues.  You see, the code I provided I 
>> had taken from a static (.sats) and dynamic (.dats) file in order to make 
>> it more presentable when asking for help.  Your fix only fixes the issue in 
>> the single-file version, and when including the external static file it 
>> doesn't work.  Do you know what might be going wrong?  I'll provide the 
>> (simplified) contents of each of these files below.
>>
>> *dict.sats*:
>> #include "share/atspre_staload.hats"
>>
>>
>> datavtype BUCKET (a:vt@ype) =
>> | bucket_empty of ()
>> | bucket_filled of (Strptr1, a, BUCKET(a))
>>
>> vtypedef bucket(a:vt@ype) = BUCKET(a)
>>
>> fn{a:vt@ype} bucket_item$delete ( x: a ): void
>>
>> fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
>>
>> sortdef dsz = {s:int | s > 0}
>>
>> vtypedef dict(a:vt@ype, n:int) =
>> @{
>> size=int n,
>> buckets=arrayptr(bucket(a), n)
>> }
>>
>> fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
>> fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
>> fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
>>
>>
>> *dict.dats*:
>> #include "share/atspre_staload.hats"
>>
>> staload "./dict.sats"
>>
>> local
>> in
>>
>>
>> implement{a} dict_new {s} ( size ) = let
>> val size_st = size_of_int(size)
>> val bucket_arr = arrayptr_make_uninitized(size_st)
>> implmnt array_initize$init (i, x) = x := bucket_empty()
>> val () = arrayptr_initize(bucket_arr, size_st)
>> in
>> @{size=size, buckets=bucket_arr}:dict(a, s)
>> end
>>
>> implmnt{a} dict_delete ( d ) = let
>>   implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
>> in
>>   dict_delete_lin(d)
>> end
>>
>> implmnt{a} bucket_delete_recursive ( b ) =
>> case+ b of
>> | ~bucket_empty() => ()
>> | ~bucket_filled(str, x, next_bucket) => let
>> val () = strptr_free(str)
>> val () = bucket_item$delete(x)
>> in
>> bucket_delete_recursive(next_bucket)
>> end
>>
>> implmnt{a} dict_delete_lin ( d ) = let
>>   implmnt array_uninitize$clear (i, x) = 
>> bucket_delete_recursive(x)
>> in
>>   arrayptr_freelin(d.buckets, size_of_int(d.size))
>> end
>> end
>>
>> *dict_test.dats*, where main is:
>> #include "share/atspre_staload.hats"
>>
>> staload "./dict.sats"
>>
>>
>> implmnt main0 () = let
>>   var d = dict_new(13)
>> in
>>   dict_delete(d)
>> end
>>
>> *My output*:
>> $ patscc --gline -DATS_MEMALLOC_LIBC dict_test.dats
>>
>> In file included from dict_test_dats.c:15:
>> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats: In function 
>> ‘mainats_0_void’:
>> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: error: 
>> ‘PMVtmpltcstmat’ undeclared (first use in this function)
>>58 |   var d = dict_new(13)
>>   | ^~~   
>>
>> /usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37:
>>  
>> note: in definition of macro ‘ATSINSmove’
>>   276 | #define ATSINSmove(tmp, val) (tmp = val)
>>   | ^~~
>> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: note: each 
>> undeclared identifier is reported only once for each function it appears in
>>58 |   var d = dict_new(13)
>>   | ^~~   
>>
>> /usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37:
>>  
>> note: in definition of macro ‘AT

Re: Help with Templates, cannot find missing implementation somewhere...

2021-11-30 Thread d4v3y_5c0n3s
Update:
I was able to get the code I provided above running by staloading the 
dict.dats file from the dict_test.dats file using " staload _ = 
"./dict.dats" ".  Now, my only problem is that if I make the "dict" & 
bucket types abstract, the templates stop working.

On Tuesday, November 30, 2021 at 1:39:39 PM UTC-5 d4v3y_5c0n3s wrote:

> You are right, including " share/atspre_staload.hats" causes the code to 
> compile.  However, I'm still having issues.  You see, the code I provided I 
> had taken from a static (.sats) and dynamic (.dats) file in order to make 
> it more presentable when asking for help.  Your fix only fixes the issue in 
> the single-file version, and when including the external static file it 
> doesn't work.  Do you know what might be going wrong?  I'll provide the 
> (simplified) contents of each of these files below.
>
> *dict.sats*:
> #include "share/atspre_staload.hats"
>
>
> datavtype BUCKET (a:vt@ype) =
> | bucket_empty of ()
> | bucket_filled of (Strptr1, a, BUCKET(a))
>
> vtypedef bucket(a:vt@ype) = BUCKET(a)
>
> fn{a:vt@ype} bucket_item$delete ( x: a ): void
>
> fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
>
> sortdef dsz = {s:int | s > 0}
>
> vtypedef dict(a:vt@ype, n:int) =
> @{
> size=int n,
> buckets=arrayptr(bucket(a), n)
> }
>
> fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
> fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
> fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
>
>
> *dict.dats*:
> #include "share/atspre_staload.hats"
>
> staload "./dict.sats"
>
> local
> in
>
>
> implement{a} dict_new {s} ( size ) = let
> val size_st = size_of_int(size)
> val bucket_arr = arrayptr_make_uninitized(size_st)
> implmnt array_initize$init (i, x) = x := bucket_empty()
> val () = arrayptr_initize(bucket_arr, size_st)
> in
> @{size=size, buckets=bucket_arr}:dict(a, s)
> end
>
> implmnt{a} dict_delete ( d ) = let
>   implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
> in
>   dict_delete_lin(d)
> end
>
> implmnt{a} bucket_delete_recursive ( b ) =
> case+ b of
> | ~bucket_empty() => ()
> | ~bucket_filled(str, x, next_bucket) => let
> val () = strptr_free(str)
> val () = bucket_item$delete(x)
> in
> bucket_delete_recursive(next_bucket)
> end
>
> implmnt{a} dict_delete_lin ( d ) = let
>   implmnt array_uninitize$clear (i, x) = 
> bucket_delete_recursive(x)
> in
>   arrayptr_freelin(d.buckets, size_of_int(d.size))
> end
> end
>
> *dict_test.dats*, where main is:
> #include "share/atspre_staload.hats"
>
> staload "./dict.sats"
>
>
> implmnt main0 () = let
>   var d = dict_new(13)
> in
>   dict_delete(d)
> end
>
> *My output*:
> $ patscc --gline -DATS_MEMALLOC_LIBC dict_test.dats
>
> In file included from dict_test_dats.c:15:
> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats: In function 
> ‘mainats_0_void’:
> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: error: 
> ‘PMVtmpltcstmat’ undeclared (first use in this function)
>58 |   var d = dict_new(13)
>   | ^~~   
>
> /usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37:
>  
> note: in definition of macro ‘ATSINSmove’
>   276 | #define ATSINSmove(tmp, val) (tmp = val)
>   | ^~~
> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:21: note: each 
> undeclared identifier is reported only once for each function it appears in
>58 |   var d = dict_new(13)
>   | ^~~   
>
> /usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37:
>  
> note: in definition of macro ‘ATSINSmove’
>   276 | #define ATSINSmove(tmp, val) (tmp = val)
>   | ^~~
> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:39: error: 
> ‘dict_new’ undeclared (first use in this function)
>58 |   var d = dict_new(13)
>
>   |   ^   
> /usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37:
>  
> note: in definition of macro ‘ATSINSmove’
>   276 | #define ATSINSmove(tmp, val) (tmp = val)
>   | ^~~
> /home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:48: warning: 
> implicit declaration of function ‘S2Eapp’ [-Wimplicit-function-declaration]
>58 |  

Re: Help with Templates, cannot find missing implementation somewhere...

2021-11-30 Thread d4v3y_5c0n3s
rset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:74: error: 
expected ‘)’ before ‘;’ token
   58 |   var d = dict_new(13)
  
|  ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:58:101: error: 
expected expression before ‘)’ token
   58 |   var d = dict_new(13)
  
|   
  
^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:44: error: 
‘dict_delete’ undeclared (first use in this function); did you mean 
‘timer_delete’?
   60 |   dict_delete(d)
  |^  
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:82: error: 
expected ‘)’ before ‘;’ token
   60 |   dict_delete(d)
  
|   
   
^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:60:109: error: 
expected expression before ‘)’ token
   60 |   dict_delete(d)
  
|   
  
^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro ‘ATSINSmove_void’
  284 | #define ATSINSmove_void(tmp, command) command
  |   ^~~
On Tuesday, November 30, 2021 at 11:28:47 AM UTC-5 gmhwxi wrote:

> I tried your code and it compiled without any issue.
>
> Did you have the following line at the top:
>
> #include "share/atspre_staload.hats"
>
> The error messages you showed indicate that many template implementations 
> were not
> available to the compiler (patsopt).
>
> --Hongwei
>
>
> On Tue, Nov 30, 2021 at 10:52 AM d4v3y_5c0n3s  wrote:
>
>> Okay, so I've been struggling with my use of templates for a while 
>> now, and I'm making this post to get some more eyes on the issue.  I've 
>> been getting really frustrated, because nothing I've tried seems to work, 
>> and I have no way to understand what is going wrong whatsoever besides 
>> becoming familiar with compiler internals (which could take who knows how 
>> long to learn.)
>>
>> Here's my code:
>> datavtype BUCKET (a:vt@ype) =
>> | bucket_empty of ()
>> | bucket_filled of (Strptr1, a, BUCKET(a))
>>
>> vtypedef bucket(a:vt@ype) = BUCKET(a)
>>
>> sortdef dsz = {s:int | s > 0}
>>
>> vtypedef dict(a:vt@ype, n:int) =
>> @{
>> size=int n,
>> buckets=arrayptr(bucket(a), n)
>> }
>>
>> extern fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
>> extern fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
>> extern fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void
>>
>> extern fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
>> extern fn{a:vt@ype} bucket_item$delete ( x: a ): void
>>
>> implement{a} dict_new {s} ( size ) = let
>> val size_st = size_of_int(size)
>> val bucket_arr = arrayptr_make_uninitized(size_st)
>> implmnt array_initize$init (i, x) = x := bucket_empty()
>> val () = arrayptr_initize(bucket_arr, size_st)
>> in
>> @{size=size, buckets=bucket_arr}:dict(a, s)
>> end
>>
>> implmnt{a} dict_delete ( d ) = let
>>   implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
>> in
>>   dict_delete_lin(d)
>> end
>>
>> implmnt{a} bucket_delete_recursive ( b ) =
>> case+ b of
>> | ~bucket_empty() => ()
>> | ~bucket_filled(str, x, next_bucket) => let
>> val () = strptr_free(str)
>> val ()

Help with Templates, cannot find missing implementation somewhere...

2021-11-30 Thread d4v3y_5c0n3s
Okay, so I've been struggling with my use of templates for a while now, 
and I'm making this post to get some more eyes on the issue.  I've been 
getting really frustrated, because nothing I've tried seems to work, and I 
have no way to understand what is going wrong whatsoever besides becoming 
familiar with compiler internals (which could take who knows how long to 
learn.)

Here's my code:
datavtype BUCKET (a:vt@ype) =
| bucket_empty of ()
| bucket_filled of (Strptr1, a, BUCKET(a))

vtypedef bucket(a:vt@ype) = BUCKET(a)

sortdef dsz = {s:int | s > 0}

vtypedef dict(a:vt@ype, n:int) =
@{
size=int n,
buckets=arrayptr(bucket(a), n)
}

extern fn{a:vt@ype} dict_new {s:dsz} ( int s ) : dict(a, s)
extern fn{a:t@ype} dict_delete {s:dsz} ( d: dict(a, s) ) : void
extern fn{a:vt@ype} dict_delete_lin {s:dsz} ( d: dict(a, s) ) : void

extern fun{a:vt@ype} bucket_delete_recursive ( b: bucket(a) ) : void
extern fn{a:vt@ype} bucket_item$delete ( x: a ): void

implement{a} dict_new {s} ( size ) = let
val size_st = size_of_int(size)
val bucket_arr = arrayptr_make_uninitized(size_st)
implmnt array_initize$init (i, x) = x := bucket_empty()
val () = arrayptr_initize(bucket_arr, size_st)
in
@{size=size, buckets=bucket_arr}:dict(a, s)
end

implmnt{a} dict_delete ( d ) = let
  implmnt(a2:t@ype) bucket_item$delete ( x ) = ()
in
  dict_delete_lin(d)
end

implmnt{a} bucket_delete_recursive ( b ) =
case+ b of
| ~bucket_empty() => ()
| ~bucket_filled(str, x, next_bucket) => let
val () = strptr_free(str)
val () = bucket_item$delete(x)
in
bucket_delete_recursive(next_bucket)
end

implmnt{a} dict_delete_lin ( d ) = let
  implmnt array_uninitize$clear (i, x) = 
bucket_delete_recursive(x)
in
  arrayptr_freelin(d.buckets, size_of_int(d.size))
end

implmnt main0 () = let
  var d = dict_new(13)
in
  dict_delete(d)
end


Here's the output:
$ patscc --gline dict_test.dats
In file included from dict_test_dats.c:15:
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats: In function 
‘_057_home_057_tmj90_057_Goldelish_055_Engine_057_source_057_data_057_dict_test_056_dats__dict_new__0__1’:
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:21: error: 
‘PMVtmpltcstmat’ undeclared (first use in this function)
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  | ^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:21: note: each 
undeclared identifier is reported only once for each function it appears in
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  | ^~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:39: error: 
‘arrayptr_make_uninitized’ undeclared (first use in this function)
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  |   ^~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:64: warning: 
implicit declaration of function ‘S2Eapp’ [-Wimplicit-function-declaration]
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  |^~   
 
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:71: warning: 
implicit declaration of function ‘S2Ecst’ [-Wimplicit-function-declaration]
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  
|   
^ 
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
  | ^~~
/home/tmj90/Goldelish-Engine/source/data/dict_test.dats:24:78: error: 
‘BUCKET’ undeclared (first use in this function)
   24 | val bucket_arr = arrayptr_make_uninitized(size_st)
  
|  
^ 
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 

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
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/d58686a2-e910-4ab4-bfe3-e33fd1bc312dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 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
>>>  
>>> <https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/4794ec8f-4b17-4d45-9ffe-60d963756e30n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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.


Template Issue

2021-11-29 Thread d4v3y_5c0n3s
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.


Re: Template Debugging Tips?

2021-11-27 Thread d4v3y_5c0n3s
Yea, I just wish ATS was better about telling me what I'm doing wrong with 
templates.  An "X is unimplemented for type Y" message would save me hours 
of work (but I suspect that would greatly increase the compiling overhead 
of templates.)

On Saturday, November 27, 2021 at 9:07:01 AM UTC-5 vamc...@gmail.com wrote:

> I recall getting errors in the generated C code when I forgot to implement 
> some function!
>
> (I was able to use them :)
>
>
> http://blog.vmchale.com/article/ats-templates
>
> Cheers,
> Vanessa McHale
>
> On Nov 27, 2021, at 9:05 AM, d4v3y_5c0n3s  wrote:
>
>   Recently, I've been working on testing the code for an ATS project I've 
> been working on for a while now.  Everything (that I've implemented) passes 
> type-checking so far.  However, I've encountered some kind of issue with 
> the templates that I've written (which all typecheck) where when I try to 
> use them some kind of error shows up in the resulting C code.
>   I suspect that I've made a mistake somewhere, but I am struggling to 
> debug the resulting code.  Is there some resource where I can gain a 
> greater understanding of either how the C code ATS produces is constructed 
> or how to debug my templates?  This has been driving me up the wall trying 
> to figure out recently, so I wanted to ask the community if they knew 
> anything that could help me.
>   The two files I am trying to use are dict.sats 
> <https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/data/dict.sats>
>  
> & dict.dats 
> <https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/data/dict.dats>
>  
> (a dictionary implementation.)  Please let me know if you have any 
> questions or would like to see more details.
>
> -- 
> 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/0f2d7e48-ddf1-4db0-8bd9-cfee6f37bbb3n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ats-lang-users/0f2d7e48-ddf1-4db0-8bd9-cfee6f37bbb3n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
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/ded23afd-5c07-40a4-937a-03643e1bb4e8n%40googlegroups.com.


Template Debugging Tips?

2021-11-27 Thread d4v3y_5c0n3s
  Recently, I've been working on testing the code for an ATS project I've 
been working on for a while now.  Everything (that I've implemented) passes 
type-checking so far.  However, I've encountered some kind of issue with 
the templates that I've written (which all typecheck) where when I try to 
use them some kind of error shows up in the resulting C code.
  I suspect that I've made a mistake somewhere, but I am struggling to 
debug the resulting code.  Is there some resource where I can gain a 
greater understanding of either how the C code ATS produces is constructed 
or how to debug my templates?  This has been driving me up the wall trying 
to figure out recently, so I wanted to ask the community if they knew 
anything that could help me.
  The two files I am trying to use are dict.sats 

 
& dict.dats 

 
(a dictionary implementation.)  Please let me know if you have any 
questions or would like to see more details.

-- 
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/0f2d7e48-ddf1-4db0-8bd9-cfee6f37bbb3n%40googlegroups.com.


Re: Why aren't the MUL() prop functions in the prelude docs? (on the site, that is)

2021-10-30 Thread d4v3y_5c0n3s
Done.

On Saturday, October 30, 2021 at 10:53:30 AM UTC-4 gmhwxi wrote:

> Yes, please open an issue about it. Thanks!
>
> On Saturday, October 30, 2021 at 10:20:03 AM UTC-4 d4v3y_5c0n3s wrote:
>
>> I just noticed that the MUL() proof functions like "mul_gte_gte_gte()" 
>> are actually not listed in the prelude reference on the "ats-lang.org" 
>> site.  Is this intended?  Should open an issue on Github about it or 
>> something?
>>
>

-- 
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/07c6fc40-e5a4-42f7-b178-ccbbc8626b5dn%40googlegroups.com.


Why aren't the MUL() prop functions in the prelude docs? (on the site, that is)

2021-10-30 Thread d4v3y_5c0n3s
I just noticed that the MUL() proof functions like "mul_gte_gte_gte()" are 
actually not listed in the prelude reference on the "ats-lang.org" site.  
Is this intended?  Should open an issue on Github about it or something?

-- 
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/6cf0c076-9f3d-4718-bc16-baa1dcede288n%40googlegroups.com.


Re: What is the best way to turn a file into a lazy linear stream?

2021-10-17 Thread d4v3y_5c0n3s
Okay, so looking back I should have provided more details in the last 
post, as it does not explain the issues I was encountering etc.  I posted 
it right before I went to bed, and that's why I rushed it.
Anyways, I wanted to explain how I solved my problem so that others 
could learn.  Basically, I was using ATS' built-in libc binding to open and 
read a file.  The pointer for the file was a linear type, I wasn't using 
the prelude's non-linear file type.  What my code did is read characters to 
a 'stream_vt' with the 'getc' function until it reached the end of the 
file.  I also planned to have other functions that would discard parts of 
the stream I didn't need so that I could turn the values I needed into 
other values (AKA, typical file-parsing stuff.)  The problem came when I 
needed to close the file.  Despite the use of linear types, freeing the 
file pointer would not prevent the stream from being access due to its 
laziness.  My solution was to essentially combine the view for the file 
pointer and the stream into a single type, and thus requiring both to be 
freed at once.
Moral of the story?  Linear types are amazing, one of the reasons I 
love ATS, but they are *not* a silver bullet.  They too are limited by what 
can be statically inferred by the compiler, and effects such as lazy values 
cannot be predicted by the compiler.  I hope someone was able to learn 
something from my post, and let me know if you have any questions.

On Monday, October 4, 2021 at 9:17:38 PM UTC-4 d4v3y_5c0n3s wrote:

>
> What the title says.  Basically, I want to use a solution that:
>  - does not require GC
>  - uses the type system to prevent the user from freeing the file before 
> they are done with the lazy evaluation
>  - is not too inconvenient for the user to use
> Let me know if you need an example of what I'm talking about.
>

-- 
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/30ae88cd-f49a-4356-8b5d-8b5ddf82efa3n%40googlegroups.com.


Re: Lambdas that use linear resources

2021-10-07 Thread d4v3y_5c0n3s
First, let me say that lambdas are one part of ATS that I'm not super 
experienced in myself.  However, if you haven't been there already, I'd 
recommend reading the chapters on linear & stack-allocated closures in the 
" A Tutorial on Programming Features in ATS " here 
 & 
here  
respectively.

Now, to answer your questions:

   1. (Why is it failing to compile?)  Your lambda doesn't see "acc", the 
   easiest way to solve this is to *pass "acc" to your lambda via reference* 
   (aka use the "&" operator in the function argument.)
  1. Side note: You don't need to say "x: !int", *because "int" is not 
  a linear type*, you can leave it "x: int" without the "!" part.
  2. (Is it possible to avoid the UNSAFE cast?)  The page I linked to 
   you above about linear closure says that yes, there is a way, but that it's 
   cumbersome to use.  That's all I know, I've not seen any example code.
   3. (Can I do this with a stack allocated closure?)  Yes, and in fact 
   it's probably better to use a stack allocated closure in this instance 
   because you are not keeping the closure around to use with multiple 
   functions.  Were you storing this closure in a struct for example, then a 
   linear closure should be used.

Let me know if you have any other questions, and good luck!

On Monday, October 4, 2021 at 11:19:34 PM UTC-4 mark.l@gmail.com wrote:

> Hi all,
>
> I'm trying to understand higher-order programming in ATS better, but I 
> keep running into errors when my lambdas use linear resources.  Here's a 
> small example that doesn't compile:
>
> extern fn {a,b:vt@ype} map_vt {n:nat} {e:eff} (
>   l: !list_vt(a, n), f: !(!a) - b
> ): list_vt(b, n)
>
> fn prefix_sums {n:nat} (l: !list_vt(int, n)): list_vt(int, n) =
>   let
> var acc: int = 0
> val f = lam(x: !int): int = (acc := acc + x; acc)
> val result = map_vt(l, f)
> val () = cloptr_free{void}($UNSAFE.castvwtp0(f))
>   in result end
>
> Compiling this gives an error saying that proof search for the view at 
> 'acc' failed.
>
> So, my questions are:
> 1. Why is this failing to compile, and how can I fix it? (Ideally without 
> threading through an 'env' view parameter to all the closures.)
> 2. Is there a way to avoid the UNSAFE cast?
> 3. Would there be a way to do it with a stack allocated closure?
>
> Thanks!
>
> -Mark
>
>

-- 
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/aee5f45c-e423-40ba-b471-3344c280f64dn%40googlegroups.com.


What is the best way to turn a file into a lazy linear stream?

2021-10-04 Thread d4v3y_5c0n3s

What the title says.  Basically, I want to use a solution that:
 - does not require GC
 - uses the type system to prevent the user from freeing the file before 
they are done with the lazy evaluation
 - is not too inconvenient for the user to use
Let me know if you need an example of what I'm talking about.

-- 
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/90db8fda-101b-492b-b92e-e9953990874en%40googlegroups.com.


Re: FILEREF type is non-linear?

2021-07-22 Thread d4v3y_5c0n3s
Thanks for the help, I was curious about FILEref because I will soon need 
to work with files in my ATS project.  I hope AT3's development is going 
well! :)

On Sunday, July 18, 2021 at 2:18:00 PM UTC-4 gmhwxi wrote:

>
>
> FILEref is abstract; it is just FILE* in C. As it is non-linear, you
> need to remember to close an opened file handle of this type.
>
> BTW, FILEptr is linear; so the type system help you keep track of
> file handles of the type FILEptr.
>
> --Hongwei
>
> PS: I often use FILEref first. If needed later, I can always change
> it to FILEptr and the typechecker will then lead me to all the places
> where subsequent changes are needed for such a change.
>
> On Sunday, July 11, 2021 at 8:02:39 PM UTC-4 d4v3y_5c0n3s wrote:
>
>> Just a quick question: I noticed that the "FILEREF" type in ATS is 
>> non-linear.  Does this mean that I need to enable garbage collection to 
>> work with files?  Or is the value freed but hidden from the linear type 
>> system?
>
>

-- 
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/d8052ecd-0d55-4f30-b95a-fa15e4e7c2b2n%40googlegroups.com.


FILEREF type is non-linear?

2021-07-11 Thread d4v3y_5c0n3s
Just a quick question: I noticed that the "FILEREF" type in ATS is 
non-linear.  Does this mean that I need to enable garbage collection to 
work with files?  Or is the value freed but hidden from the linear type 
system?

-- 
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/173749e6-6780-4c73-a05e-d3aac486772cn%40googlegroups.com.


Re: Trying to get a dependent type working in ATS

2021-07-01 Thread d4v3y_5c0n3s
You're right, when I sent this message I was too tired to realize what was 
wrong I guess.  Thanks for the help.  :)

On Wednesday, June 30, 2021 at 10:19:23 PM UTC-4 gmhwxi wrote:

> First, tri_test(0) is just:
>
> [un:int | 0 <= un; un+1 <= 0; un == 0; 0 == 0] int(un)
>
> Clearly, no value can be given the above type as 0 <= un and un+1 <= 0
> yields a contradiction.
>
>
> On Wed, Jun 30, 2021 at 10:12 PM d4v3y_5c0n3s  wrote:
>
>> So, I'm trying to get the following code to work:
>> *typedef tri_test2(v:int) = [un:int | 0 <= un; un+1 <= v; un == 0; v == 
>> 0] int(un)*
>> *val test2 = (0):tri_test2(0)*
>> But I get the following error:
>> */tmp/patsopt_tcats_TCES3d: 196(line=6, offs=14) -- 197(line=6, offs=15): 
>> error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eapp(S2Ecst(<=); 
>> S2Eapp(S2Ecst(+); S2EVar(0->S2Eintinf(0)), S2Eintinf(1)), S2Eintinf(0)))*
>> *typechecking has failed: there are some unsolved constraints: please 
>> inspect the above reported error message(s) for information.*
>> *exit(ATS): uncaught exception: 
>> _2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)*
>> I am clueless as to why I keep getting this error.  What is ATS having 
>> trouble understanding here?
>>
>> -- 
>> 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/3e48e488-e255-46d0-b6b7-3bab7fb538ban%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/3e48e488-e255-46d0-b6b7-3bab7fb538ban%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/6ef823ae-ba50-4ad6-9717-0d64705e9b60n%40googlegroups.com.


Trying to get a dependent type working in ATS

2021-06-30 Thread d4v3y_5c0n3s
So, I'm trying to get the following code to work:
*typedef tri_test2(v:int) = [un:int | 0 <= un; un+1 <= v; un == 0; v == 0] 
int(un)*
*val test2 = (0):tri_test2(0)*
But I get the following error:
*/tmp/patsopt_tcats_TCES3d: 196(line=6, offs=14) -- 197(line=6, offs=15): 
error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eapp(S2Ecst(<=); 
S2Eapp(S2Ecst(+); S2EVar(0->S2Eintinf(0)), S2Eintinf(1)), S2Eintinf(0)))*
*typechecking has failed: there are some unsolved constraints: please 
inspect the above reported error message(s) for information.*
*exit(ATS): uncaught exception: 
_2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)*
I am clueless as to why I keep getting this error.  What is ATS having 
trouble understanding here?

-- 
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/3e48e488-e255-46d0-b6b7-3bab7fb538ban%40googlegroups.com.


Re: Memory Mapped IO

2021-06-26 Thread d4v3y_5c0n3s
Sorry for the delay on this response.

Basically, as for having ATS thing that a pointer is valid, you'd 
create an "extern" function like this:
extern fn name_here () : [l:addr] (typename @ l | ptr l)//  where this 
function points to something in C

As for not having to "psuedo-free" the return value every time you are 
done with it, there are several things that can be done.  First, in certain 
instances you can use templates to make things easier to manage, but 
explaining exactly what I mean is kind of difficult to articulate over 
Google Groups.  You'll have to take my word for it, and you'll likely 
understand when you play with templates more.
Second, this "psuedo-free" issue is a natural consequence of using 
linear types, these restrictions are designed to make resources less likely 
to be mismanaged.  Rather than trying to avoid this pattern completely, I'd 
suggest formalizing this relationship with ATS' type system.  I'd take a 
look at the "Reader and Writer" pattern here to get an idea of what I'm 
suggesting.  Basically, you'd have a view for the memory IO that acts as a 
"key" of sorts.  Whenever you call the function I suggested above, this 
view would be consumed, preventing anyone else from calling that function.  
When you are done, you'd call another function that consumes this pointer 
to the memory IO and gives you back the "key" view.  Now, you can call the 
first function again since you've finished touching that memory.  The 
benefit of doing this is that wouldn't have to worry about things like 
calling the function at the same time in concurrent code.  It also looks 
better, so there's that.

On Thursday, June 3, 2021 at 6:35:40 PM UTC-4 d4v3y_5c0n3s wrote:

> I'd suggest using an external function/value with dependent types that 
> tell ATS the "sort" of the pointer is "agz" (arguements greater than 
> zero.)  I'll try to put together an example.
>
> On Thu, Jun 3, 2021, 6:15 PM David Smith  wrote:
>
>>
>> When dealing with memory mapped IO, is there a neat way to axiomatically 
>> say "there is something at address 0x12345678?
>>
>> At the moment I'm using a C macro that just returns the address, and then 
>> have an at-view in the ATS type signature, though I'd prefer to somehow 
>> treat that as global, if only so I don't have to "pseudo-free" the stuff 
>> every time I use it.
>>
>> Thanks in advance.
>>
>> -- 
>> 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/baa3dbd2-410f-44d5-be2e-2bbd6e7efcf5n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/baa3dbd2-410f-44d5-be2e-2bbd6e7efcf5n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/2f7132c7-71d8-4d91-bebd-2bd67215a226n%40googlegroups.com.


Re: Moving forward with ATS3

2021-06-03 Thread d4v3y_5c0n3s
Exciting!  I can't wait! :D

On Thursday, June 3, 2021 at 6:31:11 PM UTC-4 gmhwxi wrote:

>
> Hi, there,
>
> I wish I could announce that ATS is ready. But it is not.
>
> I had actually gotten stuck for quite some time in the middle of
> implementing a type-checker for ATS3 (that supports both linear
> types and dependent types). It is some work I did in the last few
> days that has unstuck me. Hopefully :) I can now move forward
> again with the implementation.
>
> At this point, I feel that I have a pretty good picture as to what ATS3
> is going to be like as a programming language. However, it is not so
> clear to me as to what kind of an ecosystem can be built for this unique
> programming language. I would definitely want to hear from people on
> this list and elsewhere.
>
> I will be soon sending out some posts talking about various aspects of
> ATS3. Let's have a lively discussion :)
>
> Cheers!
>
> --Hongwei
>
>
>
>

-- 
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/9f1c2c9b-96c0-4b69-a24c-4bbb4aa0b8b7n%40googlegroups.com.


Re: "Number is smaller than 0x8000, trust me"

2021-05-29 Thread d4v3y_5c0n3s
Hey David, have you tried using the "praxi" syntax?  It allows you to 
define an axiom, essentially telling ATS: "I'm not going to prove that X is 
true, but just assume it is."  I'd recommend reading the theorem proving 
sections of Intro to ATS if you haven't already.

Here's an example of a praxi that should suit your needs:
sortdef invals = {iv:int | iv < 0x20}
praxi lor_assumption {a,b,c:invals}{r:int} (
a:int a, b:int b, c:int c,
result: int r
) : [r < 0x8000] void

If you'd like me to explain what I'm doing here, just ask me and I can tell 
you how this works.  (By the way, I tested and this code compiles.)

On Sunday, May 23, 2021 at 7:22:52 PM UTC-4 gmhwxi wrote:

> This kind of guarantee can always be established with a run-time check.
>
> If you want to solve constraints involving 'lor', then you need to use an 
> external solver like Z3.
> But it would require a lot of effort.
>
> I would suggest using a run-time check for now. And you could always come 
> back to fix it later
> if really needed.
>
> On Sun, May 23, 2021 at 6:28 PM David Smith  wrote:
>
>>
>> Hey, I have a small convenience function that takes 3 5 bit bit numbers 
>> to produce a 15 bit color, that's guaranteed to be <0x8000.
>>
>> Now, apparently the typechecker doesn't know much about `lor`. Is there 
>> any way I could say "hey trust me, if these three numbers are < 0x20 then 
>> the result is < 0x8000"?
>>
>> Thanks in advance.
>>
>> -- 
>>
> 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/4f5589ed-b80d-4662-918c-ac1fa81d04c9n%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/f4a64ead-e20c-4389-a5d2-dbad4f7d8254n%40googlegroups.com.


Re: Having Trouble Finding a Constraint Which is Failing

2021-05-08 Thread d4v3y_5c0n3s
Yea, that would make more sense.  I guess I still don't fully understand 
how to read constraint errors.  Thanks for letting me know.

On Saturday, May 8, 2021 at 9:30:11 PM UTC-4 ice.r...@gmail.com wrote:

> and by the way, the failing constraint was f1 == f1+1
>
> сб, 8 мая 2021 г. в 22:09, d4v3y_5c0n3s :
>
>> Thanks, I appreciate the help.  I'm glad that the issue was a simple fix. 
>> :D
>>
>> On Saturday, May 8, 2021 at 3:14:33 PM UTC-4 gmhwxi wrote:
>>
>>> This is due to a missing type annotation for 'ifcase'
>>> in your code:
>>>
>>> val ret_fbc =
>>> (
>>>
>>> ifcase
>>> | tr=0 =>
>>>   (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
>>> | tr=1 =>
>>>   (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
>>> | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
>>> ) : [f1,b1:nat] fb_count(a, f1, b1)
>>>
>>> In general, if-exp, case-exp and ifcase-exp should all be given a type 
>>> annotation.
>>>
>>>
>>> On Sat, May 8, 2021 at 9:39 AM d4v3y_5c0n3s  wrote:
>>>
>>>> So, I'm having difficulty understanding a constraint that is 
>>>> failing in my code.  The constraint that is failing is "f1 + f1 = 1", 
>>>> which 
>>>> I am confused by, because there appears to be no such constraint in my 
>>>> code.
>>>> *Here's what (most of) my code is:*
>>>> dataprop FBT_IN (int, a:addr) =
>>>> | FBT_NIL(0, a)
>>>> | {n:nat} FBT_CONS(n+1, a) of FBT_IN(n, a)
>>>> 
>>>> typedef fb_count (a:addr, f:int, b:int) = [c:nat | f >= 0; b >= 
>>>> 0] (FBT_IN(c, a) | int f, int b)
>>>> typedef f_ind (a:addr, f:int, i:int) = int i
>>>> typedef b_ind (a:addr, b:int, i:int) = int i
>>>> 
>>>> fn tri_fb_test {c:nat}{l:addr}
>>>> (
>>>> pfin: FBT_IN(c, l) | t: ctri, dv: plane
>>>> ): (FBT_IN(c+1, l) | intBtwe(0,2)) =
>>>>   if ctri_inside_plane(t, dv) then (FBT_CONS(pfin) | 0)
>>>>   else if ctri_outside_plane(t, dv) then (FBT_CONS(pfin) | 1)
>>>>   else (FBT_CONS(pfin) | 2)
>>>> 
>>>> fun loop1 {i,j:nat | i <= j}{a:addr}{f1,b1:nat}
>>>> ( a: !arrayptr(ctri, a, j), dv: plane,
>>>> fbc: fb_count(a, f1, b1),
>>>> j: int j, i: int i ): [f2,b2:nat] fb_count(a, f2, b2) = (
>>>>   if i < j then let
>>>> val c: ctri = a[i]
>>>> val (pf_tr | tr) = tri_fb_test(fbc.0 | c, dv)
>>>> val ret_fbc = ifcase
>>>>   | tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
>>>>   | tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
>>>>   | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
>>>>   in
>>>> loop1(a, dv, ret_fbc, j, i+1)  // <-- constraint fails on 
>>>> this line at "ret_fbc"
>>>>   end else fbc
>>>> *And here's the error produced:*
>>>> $ patscc -tcats cmesh.dats
>>>> /home/tmj90/Goldelish-Engine/source/assets/cmesh.dats: 8604(line=235, 
>>>> offs=26) -- 8611(line=235, offs=33): error(3): unsolved constraint: 
>>>> C3NSTRprop(C3TKmain(); S2Eeqeq(S2Evar(f1(8784)); 
>>>> S2Eapp(S2Ecst(add_int_int); S2Evar(f1(8784)), S2Eintinf(1
>>>> typechecking has failed: there are some unsolved constraints: please 
>>>> inspect the above reported error message(s) for information.
>>>> exit(ATS): uncaught exception: 
>>>> _2tmp_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
>>>>
>>>> I suspect the issue is an implicitly generated constraint of some kind, 
>>>> but I have no idea where it's coming from.  *However*, I discovered 
>>>> that if I comment out these lines:
>>>> val ret_fbc = ifcase
>>>>   //| tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
>>>>   //| tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
>>>>   | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
>>>> then everything typechecks.  That's the biggest hint I could find, but 
>>>> I don't know what going wrong.  Please let me know if you'd like me to 
>>>> provide more code, I just didn't want to c

Re: Having Trouble Finding a Constraint Which is Failing

2021-05-08 Thread d4v3y_5c0n3s
Thanks, I appreciate the help.  I'm glad that the issue was a simple fix. :D

On Saturday, May 8, 2021 at 3:14:33 PM UTC-4 gmhwxi wrote:

> This is due to a missing type annotation for 'ifcase'
> in your code:
>
> val ret_fbc =
> (
>
> ifcase
> | tr=0 =>
>   (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
> | tr=1 =>
>   (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
> | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
> ) : [f1,b1:nat] fb_count(a, f1, b1)
>
> In general, if-exp, case-exp and ifcase-exp should all be given a type 
> annotation.
>
>
> On Sat, May 8, 2021 at 9:39 AM d4v3y_5c0n3s  wrote:
>
>> So, I'm having difficulty understanding a constraint that is failing 
>> in my code.  The constraint that is failing is "f1 + f1 = 1", which I am 
>> confused by, because there appears to be no such constraint in my code.
>> *Here's what (most of) my code is:*
>> dataprop FBT_IN (int, a:addr) =
>> | FBT_NIL(0, a)
>> | {n:nat} FBT_CONS(n+1, a) of FBT_IN(n, a)
>> 
>> typedef fb_count (a:addr, f:int, b:int) = [c:nat | f >= 0; b >= 
>> 0] (FBT_IN(c, a) | int f, int b)
>> typedef f_ind (a:addr, f:int, i:int) = int i
>> typedef b_ind (a:addr, b:int, i:int) = int i
>> 
>> fn tri_fb_test {c:nat}{l:addr}
>> (
>> pfin: FBT_IN(c, l) | t: ctri, dv: plane
>> ): (FBT_IN(c+1, l) | intBtwe(0,2)) =
>>   if ctri_inside_plane(t, dv) then (FBT_CONS(pfin) | 0)
>>   else if ctri_outside_plane(t, dv) then (FBT_CONS(pfin) | 1)
>>   else (FBT_CONS(pfin) | 2)
>> 
>> fun loop1 {i,j:nat | i <= j}{a:addr}{f1,b1:nat}
>> ( a: !arrayptr(ctri, a, j), dv: plane,
>> fbc: fb_count(a, f1, b1),
>> j: int j, i: int i ): [f2,b2:nat] fb_count(a, f2, b2) = (
>>   if i < j then let
>> val c: ctri = a[i]
>> val (pf_tr | tr) = tri_fb_test(fbc.0 | c, dv)
>> val ret_fbc = ifcase
>>   | tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
>>   | tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
>>   | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
>>   in
>> loop1(a, dv, ret_fbc, j, i+1)  // <-- constraint fails on 
>> this line at "ret_fbc"
>>   end else fbc
>> *And here's the error produced:*
>> $ patscc -tcats cmesh.dats
>> /home/tmj90/Goldelish-Engine/source/assets/cmesh.dats: 8604(line=235, 
>> offs=26) -- 8611(line=235, offs=33): error(3): unsolved constraint: 
>> C3NSTRprop(C3TKmain(); S2Eeqeq(S2Evar(f1(8784)); 
>> S2Eapp(S2Ecst(add_int_int); S2Evar(f1(8784)), S2Eintinf(1
>> typechecking has failed: there are some unsolved constraints: please 
>> inspect the above reported error message(s) for information.
>> exit(ATS): uncaught exception: 
>> _2tmp_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
>>
>> I suspect the issue is an implicitly generated constraint of some kind, 
>> but I have no idea where it's coming from.  *However*, I discovered that 
>> if I comment out these lines:
>> val ret_fbc = ifcase
>>   //| tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
>>   //| tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
>>   | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
>> then everything typechecks.  That's the biggest hint I could find, but I 
>> don't know what going wrong.  Please let me know if you'd like me to 
>> provide more code, I just didn't want to clutter my initial post.
>>
>> -- 
>> 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/dcf7d7eb-d69f-4746-800b-24c02084ee65n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/dcf7d7eb-d69f-4746-800b-24c02084ee65n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/c2070b8f-d112-426c-a69a-a2c23ca2dcffn%40googlegroups.com.


Having Trouble Finding a Constraint Which is Failing

2021-05-08 Thread d4v3y_5c0n3s
So, I'm having difficulty understanding a constraint that is failing in 
my code.  The constraint that is failing is "f1 + f1 = 1", which I am 
confused by, because there appears to be no such constraint in my code.
*Here's what (most of) my code is:*
dataprop FBT_IN (int, a:addr) =
| FBT_NIL(0, a)
| {n:nat} FBT_CONS(n+1, a) of FBT_IN(n, a)

typedef fb_count (a:addr, f:int, b:int) = [c:nat | f >= 0; b >= 0] 
(FBT_IN(c, a) | int f, int b)
typedef f_ind (a:addr, f:int, i:int) = int i
typedef b_ind (a:addr, b:int, i:int) = int i

fn tri_fb_test {c:nat}{l:addr}
(
pfin: FBT_IN(c, l) | t: ctri, dv: plane
): (FBT_IN(c+1, l) | intBtwe(0,2)) =
  if ctri_inside_plane(t, dv) then (FBT_CONS(pfin) | 0)
  else if ctri_outside_plane(t, dv) then (FBT_CONS(pfin) | 1)
  else (FBT_CONS(pfin) | 2)

fun loop1 {i,j:nat | i <= j}{a:addr}{f1,b1:nat}
( a: !arrayptr(ctri, a, j), dv: plane,
fbc: fb_count(a, f1, b1),
j: int j, i: int i ): [f2,b2:nat] fb_count(a, f2, b2) = (
  if i < j then let
val c: ctri = a[i]
val (pf_tr | tr) = tri_fb_test(fbc.0 | c, dv)
val ret_fbc = ifcase
  | tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
  | tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
  | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
  in
loop1(a, dv, ret_fbc, j, i+1)  // <-- constraint fails on this 
line at "ret_fbc"
  end else fbc
*And here's the error produced:*
$ patscc -tcats cmesh.dats
/home/tmj90/Goldelish-Engine/source/assets/cmesh.dats: 8604(line=235, 
offs=26) -- 8611(line=235, offs=33): error(3): unsolved constraint: 
C3NSTRprop(C3TKmain(); S2Eeqeq(S2Evar(f1(8784)); 
S2Eapp(S2Ecst(add_int_int); S2Evar(f1(8784)), S2Eintinf(1
typechecking has failed: there are some unsolved constraints: please 
inspect the above reported error message(s) for information.
exit(ATS): uncaught exception: 
_2tmp_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)

I suspect the issue is an implicitly generated constraint of some kind, but 
I have no idea where it's coming from.  *However*, I discovered that if I 
comment out these lines:
val ret_fbc = ifcase
  //| tr=0 => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2)
  //| tr=1 => (FBT_CONS(fbc.0) | fbc.1, fbc.2+1)
  | _ => (FBT_CONS(fbc.0) | fbc.1+1, fbc.2+1)
then everything typechecks.  That's the biggest hint I could find, but I 
don't know what going wrong.  Please let me know if you'd like me to 
provide more code, I just didn't want to clutter my initial post.

-- 
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/dcf7d7eb-d69f-4746-800b-24c02084ee65n%40googlegroups.com.


Re: Finding Strings within Strings in ATS

2021-03-05 Thread d4v3y_5c0n3s
Cool!  I can't wait for the first release of ATS3, good luck and thanks!

On Thursday, March 4, 2021 at 11:35:57 AM UTC-5 gmhwxi wrote:

> Your question got me thinking :)
>
> I feel that ATS3 is not yet suitable right now.
>
> I am focusing on implementing a typechecker for linear and dependent types.
> After that, I suppose I can polish it a bit and then make a release.
>
> --Hongwei
>
>
>
> On Monday, March 1, 2021 at 9:11:13 PM UTC-5 d4v3y_5c0n3s wrote:
>
>> Thank you for the suggestions.  I decided to sidestep my need to _ for 
>> now.  While atscntrb-hx-libpcre seems like it would suit my needs, I'd 
>> rather not require people to install too many external libraries.  Is ATS3 
>> suitable for writing libraries for currently?  Because if I were to 
>> implement string processing functions it would make the most since to do it 
>> for ATS3.
>>
>> On Sunday, February 28, 2021 at 11:35:29 AM UTC-5 gmhwxi wrote:
>>
>>> Thanks for the link. I will take a look.
>>>
>>>
>>> On Saturday, February 27, 2021 at 6:04:13 PM UTC-5 Elronnd _ wrote:
>>>
>>>> On Sat, 27 Feb 2021, gmhwxi wrote: 
>>>> > As for building an ecosystem for ATS3, I am thinking about a way for 
>>>> > contributed packages to be hosted on-line. Not much progress is made 
>>>> at 
>>>> > this stage, though. 
>>>>
>>>> Have you seen 
>>>> https://github.com/vmchale/atspkg/blob/master/ats-pkg/README.md ? 
>>>>
>>>

-- 
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/933014da-e990-442f-9016-ca21912b967fn%40googlegroups.com.


Re: Finding Strings within Strings in ATS

2021-03-01 Thread d4v3y_5c0n3s
Thank you for the suggestions.  I decided to sidestep my need to _ for 
now.  While atscntrb-hx-libpcre seems like it would suit my needs, I'd 
rather not require people to install too many external libraries.  Is ATS3 
suitable for writing libraries for currently?  Because if I were to 
implement string processing functions it would make the most since to do it 
for ATS3.

On Sunday, February 28, 2021 at 11:35:29 AM UTC-5 gmhwxi wrote:

> Thanks for the link. I will take a look.
>
>
> On Saturday, February 27, 2021 at 6:04:13 PM UTC-5 Elronnd _ wrote:
>
>> On Sat, 27 Feb 2021, gmhwxi wrote:
>> > As for building an ecosystem for ATS3, I am thinking about a way for 
>> > contributed packages to be hosted on-line. Not much progress is made at 
>> > this stage, though.
>>
>> Have you seen 
>> https://github.com/vmchale/atspkg/blob/master/ats-pkg/README.md ?
>>
>

-- 
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/b563a45c-13d4-4c79-ac57-0479c78bc279n%40googlegroups.com.


Finding Strings within Strings in ATS

2021-02-25 Thread d4v3y_5c0n3s
I was searching through the prelude looking for a way to find a 
formatted string within another string in ATS, but there doesn't seem to be 
a built-in way to do this.  Before I make something myself, I just wanted 
to see what opinions there are on the best way to perform this operation in 
ATS.
Do you think I should use the C standard library through ATS' ability 
to call inline C code?  Should I just loop through a strnptr and manually 
check the chars?  Personally, I want to try using linear streams here to 
take advantage of their low-memory overhead (and because I've fallen 
straight into the "once you have a hammer everything looks like a nail" 
trap with linear streams.)  But, I want to hear what others think, so 
please let me know which solution you think is best.
As a side note, should we add more string manipulation capabilities to 
the prelude?  I don't know what Hongwei's stance on this is, but if he 
thinks it would be a good idea I'd be willing to contribute these functions 
to the prelude.

-- 
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/07c468fe-8d33-4541-bd58-a9f9e2be9b68n%40googlegroups.com.


Re: A talk by Deech on ATS

2021-02-22 Thread d4v3y_5c0n3s
Actually, "A (not so) Gentle Introduction to Systems Programming in ATS" 
was what really sold me on ATS too.  I wish I could thank him for making 
the talk, learning ATS has been an amazing experience. :D

On Sunday, February 21, 2021 at 12:41:32 AM UTC-5 ice.r...@gmail.com wrote:

> I would like to thank Aditya Siram as well. His speech "A (not so) gentle 
> introduction into a systems programming language in ATS" was one of the 
> reasons why I had actually tried to dig into ATS :)
>
> https://www.youtube.com/watch?v=zt0OQb1DBko
>
> And, as I said there in the comment section: instead of digging into 
> mainstream platforms and tools in order to gain more money, now I spent my 
> free time with ATS )
>
> So Aditya Siram makes good work on bringing ATS to masses
>

-- 
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/a432707c-5b86-499c-be54-a08921623437n%40googlegroups.com.


Re: Having Trouble Using Call-By-Reference

2021-01-22 Thread d4v3y_5c0n3s
Thank you for the help.  That makes sense, I just wanted to make sure I 
understood the problem for the future.

On Friday, January 22, 2021 at 8:30:07 AM UTC-5 gmhwxi wrote:

> (x:  &int >> _) means that the argument is call-by-reference; the integer 
> in it may be updated.
>
> BTW, (x: &int) means that the argument is read-only call-by-reference, but 
> it is not enforced in ATS2
>
> Note that (&T >> _) is just a shorthand for (&T >> T).
>
>
>
> On Fri, Jan 22, 2021 at 8:24 AM d4v3y_5c0n3s  wrote:
>
>> Thanks, this works perfectly!  By the way, what does the "&int >>  _" 
>> syntax mean in this case?
>>
>> On Friday, January 22, 2021 at 1:46:15 AM UTC-5 gmhwxi wrote:
>>
>>> There are a couple of issues. Maybe the following code is what
>>> you wanted:
>>>
>>> fn chng_int_test ( i: &int >> _ ) : void = i := i + 1
>>>
>>>
>>> fn test_chnge () : int = let
>>>   var i: int = 0
>>>
>>>   val () = chng_int_test(i)
>>> in
>>>   i
>>> end
>>> On Fri, Jan 22, 2021 at 12:51 AM d4v3y_5c0n3s  wrote:
>>>
>>>> I'm trying to use call by reference in the following example, but I'm 
>>>> running into issues trying to get it to compile.  It's late, so I'll 
>>>> explain more tomorrow, but any help is appreciated.
>>>>
>>>> fn chng_int_test ( i: &int? >> _ ) : void = i + 1
>>>>
>>>> fn test_chnge () : int = let
>>>> var i = 0
>>>> val () = chng_int_test(i)
>>>> in
>>>> i
>>>> end
>>>>
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
>>>> error(3): the dynamic expression cannot be assigned the type 
>>>> [S2Eapp(S2Ecst(g1uint_int_t0ype); S2Eextkind(atstype_size), S2EVar(0))].
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>>>> S2Eextkind(atstype_int)))
>>>> The needed term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
>>>> S2Eextkind(atstype_size), S2EVar(0))
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>>>> error(3): the linear dynamic variable [i$view$74(-1)] is preserved but 
>>>> with 
>>>> an incompatible type.
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>>>> S2Eextkind(atstype_int)))
>>>> The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>>>> S2Eextkind(atstype_int))); S2Evar(i(4314)))
>>>> The needed term is: S2Eat(S2Eapp(S2Ecst(g0int_t0ype); 
>>>> S2Eextkind(atstype_int)); S2Evar(i(4314)))
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>>>> error(3): the dynamic expression cannot be assigned the type 
>>>> [S2Ecst(atsvoid_t0ype)].
>>>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
>>>> S2Eextkind(atstype_size), S2Eapp(S2Ecst(add_int_int); S2EVar(0), 
>>>> S2Eintinf(1)))
>>>> The needed term is: S2Ecst(atsvoid_t0ype)
>>>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>>>> error(3): the linear dynamic variable [i$view$75(-1)] is preserved but 
>>>> with 
>>>> an incompatible type.
>>>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>>>> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
>>>> S2Eextkind(atstype_int), S2Eintinf(0))
>>>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>>>> error(3): mismatch of static terms (tyleq):
>>>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>>>&

Re: Having Trouble Using Call-By-Reference

2021-01-22 Thread d4v3y_5c0n3s
Thanks, this works perfectly!  By the way, what does the "&int >>  _" 
syntax mean in this case?

On Friday, January 22, 2021 at 1:46:15 AM UTC-5 gmhwxi wrote:

> There are a couple of issues. Maybe the following code is what
> you wanted:
>
> fn chng_int_test ( i: &int >> _ ) : void = i := i + 1
>
>
> fn test_chnge () : int = let
>   var i: int = 0
>
>   val () = chng_int_test(i)
> in
>   i
> end
> On Fri, Jan 22, 2021 at 12:51 AM d4v3y_5c0n3s  wrote:
>
>> I'm trying to use call by reference in the following example, but I'm 
>> running into issues trying to get it to compile.  It's late, so I'll 
>> explain more tomorrow, but any help is appreciated.
>>
>> fn chng_int_test ( i: &int? >> _ ) : void = i + 1
>>
>> fn test_chnge () : int = let
>> var i = 0
>> val () = chng_int_test(i)
>> in
>> i
>> end
>>
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
>> error(3): the dynamic expression cannot be assigned the type 
>> [S2Eapp(S2Ecst(g1uint_int_t0ype); S2Eextkind(atstype_size), S2EVar(0))].
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int)))
>> The needed term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
>> S2Eextkind(atstype_size), S2EVar(0))
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>> error(3): the linear dynamic variable [i$view$74(-1)] is preserved but with 
>> an incompatible type.
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int)))
>> The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int))); S2Evar(i(4314)))
>> The needed term is: S2Eat(S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int)); S2Evar(i(4314)))
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>> error(3): the dynamic expression cannot be assigned the type 
>> [S2Ecst(atsvoid_t0ype)].
>> /tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
>> S2Eextkind(atstype_size), S2Eapp(S2Ecst(add_int_int); S2EVar(0), 
>> S2Eintinf(1)))
>> The needed term is: S2Ecst(atsvoid_t0ype)
>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>> error(3): the linear dynamic variable [i$view$75(-1)] is preserved but with 
>> an incompatible type.
>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
>> S2Eextkind(atstype_int), S2Eintinf(0))
>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int)))
>> The needed term is: S2Etop(knd=0; S2Eapp(S2Ecst(g1int_int_t0ype); 
>> S2Eextkind(atstype_int), S2Eintinf(0)))
>> /tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
>> error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
>> S2Eextkind(atstype_int))); S2Evar(i(4313)))
>> The needed term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g1int_int_t0ype); 
>> S2Eextkind(atstype_int), S2Eintinf(0))); S2Evar(i(4313)))
>> patsopt(TRANS3): there are [4] errors in total.
>> exit(ATS): uncaught exception: 
>> _2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
>>
>> -- 
>> 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/b7580da8-275c-4d17-b796-90e81404ee5dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/b7580da8-275c-4d17-b796-90e81404ee5dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/67c75864-2a19-4035-8c9d-33e66ca1797fn%40googlegroups.com.


Having Trouble Using Call-By-Reference

2021-01-21 Thread d4v3y_5c0n3s
I'm trying to use call by reference in the following example, but I'm 
running into issues trying to get it to compile.  It's late, so I'll 
explain more tomorrow, but any help is appreciated.

fn chng_int_test ( i: &int? >> _ ) : void = i + 1

fn test_chnge () : int = let
var i = 0
val () = chng_int_test(i)
in
i
end

/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
error(3): the dynamic expression cannot be assigned the type 
[S2Eapp(S2Ecst(g1uint_int_t0ype); S2Eextkind(atstype_size), S2EVar(0))].
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 47(line=2, offs=46): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int)))
The needed term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
S2Eextkind(atstype_size), S2EVar(0))
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
error(3): the linear dynamic variable [i$view$74(-1)] is preserved but with 
an incompatible type.
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int)))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int))); S2Evar(i(4314)))
The needed term is: S2Eat(S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int)); S2Evar(i(4314)))
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
error(3): the dynamic expression cannot be assigned the type 
[S2Ecst(atsvoid_t0ype)].
/tmp/patsopt_tcats_SwYDb2: 46(line=2, offs=45) -- 51(line=2, offs=50): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g1uint_int_t0ype); 
S2Eextkind(atstype_size), S2Eapp(S2Ecst(add_int_int); S2EVar(0), 
S2Eintinf(1)))
The needed term is: S2Ecst(atsvoid_t0ype)
/tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
error(3): the linear dynamic variable [i$view$75(-1)] is preserved but with 
an incompatible type.
/tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2Eintinf(0))
/tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int)))
The needed term is: S2Etop(knd=0; S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2Eintinf(0)))
/tmp/patsopt_tcats_SwYDb2: 78(line=4, offs=26) -- 138(line=9, offs=4): 
error(3): mismatch of static terms (tyleq):
The actual term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int))); S2Evar(i(4313)))
The needed term is: S2Eat(S2Etop(knd=0; S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2Eintinf(0))); S2Evar(i(4313)))
patsopt(TRANS3): there are [4] errors in total.
exit(ATS): uncaught exception: 
_2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)

-- 
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/b7580da8-275c-4d17-b796-90e81404ee5dn%40googlegroups.com.


Re: Is It Possible to Pass a Function Template as a Parameter?

2021-01-05 Thread d4v3y_5c0n3s
I wrote my previous message pretty late, and looking back I can see that it 
makes less sense than I thought it did then.  I don't have time to break 
things down at the moment, but I will try to better explain what I was 
talking about later.
On Sunday, January 3, 2021 at 10:52:13 PM UTC-5 gmhwxi wrote:

>
> Sorry, this is still a bit unclear to me. What does a typical instance of 
> map_test look like?
> On Sunday, January 3, 2021 at 1:19:38 AM UTC-5 d4v3y_5c0n3s wrote:
>
>> Here's what I'm talking about:
>> I know that I can currently create a function template which takes in a 
>> function as a parameter, which can be observed below:
>> fn{a:vt@ype} map_test ( t: &test, mapper: a - void ) : void
>>
>> But, let's say that the 'test' typedef is as follows:
>> vtypedef test = [a:vt@ype] ( a )
>>
>> In this instance, the function 'map_test()' will not work for the type 
>> 'test' because the passed mapping function 'mapper' may not necessarily 
>> take in the correct type (the 'test' type essentially hides the type it 
>> contains.)  Of course, 'test' could be rewritten to take in a type, 
>> allowing the type checker to verify that the type within 'test' matches.  
>> Doing so would look like this:
>> vtypedef test(a:vt@ype) = ( a ) 
>>
>> But, what if I want the type within 'test' to remain hidden?  If 
>> 'mapper,' instead of being a function, was a template, then it would 
>> compile (given said template had the proper implementations.)  Essentially, 
>> instead of me wanting to verify that 'mapper' will take in the given vt@ype 
>> 'a', I want 'mapper' to reference a function template which then will be 
>> specifically implemented for any needed types.  Then, I could create a 
>> generic map function template that would work on a type which hides its 
>> contained generic type.  I'll admit, this is a pretty niche use case, but I 
>> wanted to know whether I could indeed do this.
>>
>> I've already found a way to work around this via the use of local 
>> template instantiation, which may be the better way to handle things 
>> anyways.
>>
>> Please let me know if this example is insufficient.
>> On Saturday, January 2, 2021 at 9:59:20 PM UTC-5 gmhwxi wrote:
>>
>>> Yes, I would like to see an example of this kind.
>>>
>>>
>>> On Sat, Jan 2, 2021 at 9:19 PM d4v3y_5c0n3s  wrote:
>>>
>>>> So, I know that  it's possible to pass a function to another function 
>>>> as a parameter, but what if I want to pass a function template 
>>>> specifically?  If anyone would like some clarification, I can try to 
>>>> provide some examples of what I'm trying to achieve. 
>>>>
>>>> -- 
>>>> 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/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
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/51508236-82fe-469b-b3bb-39752654483bn%40googlegroups.com.


Re: Is It Possible to Pass a Function Template as a Parameter?

2021-01-02 Thread d4v3y_5c0n3s
Here's what I'm talking about:
I know that I can currently create a function template which takes in a 
function as a parameter, which can be observed below:
fn{a:vt@ype} map_test ( t: &test, mapper: a - void ) : void

But, let's say that the 'test' typedef is as follows:
vtypedef test = [a:vt@ype] ( a )

In this instance, the function 'map_test()' will not work for the type 
'test' because the passed mapping function 'mapper' may not necessarily 
take in the correct type (the 'test' type essentially hides the type it 
contains.)  Of course, 'test' could be rewritten to take in a type, 
allowing the type checker to verify that the type within 'test' matches.  
Doing so would look like this:
vtypedef test(a:vt@ype) = ( a ) 

But, what if I want the type within 'test' to remain hidden?  If 'mapper,' 
instead of being a function, was a template, then it would compile (given 
said template had the proper implementations.)  Essentially, instead of me 
wanting to verify that 'mapper' will take in the given vt@ype 'a', I want 
'mapper' to reference a function template which then will be specifically 
implemented for any needed types.  Then, I could create a generic map 
function template that would work on a type which hides its contained 
generic type.  I'll admit, this is a pretty niche use case, but I wanted to 
know whether I could indeed do this.

I've already found a way to work around this via the use of local template 
instantiation, which may be the better way to handle things anyways.

Please let me know if this example is insufficient.
On Saturday, January 2, 2021 at 9:59:20 PM UTC-5 gmhwxi wrote:

> Yes, I would like to see an example of this kind.
>
>
> On Sat, Jan 2, 2021 at 9:19 PM d4v3y_5c0n3s  wrote:
>
>> So, I know that  it's possible to pass a function to another function as 
>> a parameter, but what if I want to pass a function template specifically?  
>> If anyone would like some clarification, I can try to provide some examples 
>> of what I'm trying to achieve. 
>>
>> -- 
>> 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/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/33bcc99a-936f-49d9-9ec6-6ec57ca4d15an%40googlegroups.com.


Is It Possible to Pass a Function Template as a Parameter?

2021-01-02 Thread d4v3y_5c0n3s
So, I know that  it's possible to pass a function to another function as a 
parameter, but what if I want to pass a function template specifically?  If 
anyone would like some clarification, I can try to provide some examples of 
what I'm trying to achieve.

-- 
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/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com.


Re: How do I work around the limitations of the typechecker?

2020-12-23 Thread d4v3y_5c0n3s
Thanks for the reply!  I'll test this out shortly and then check the 
prelude so that I understand the problem for next time. ;) I appreciate the 
help.

On Wednesday, December 23, 2020 at 2:52:42 PM UTC-5 gmhwxi wrote:

>
> Here is a way to do it:
>
> g1int_nmod(abs(g1ofg0(hash_num(0, 0))), size)
>
>
> On Wed, Dec 23, 2020 at 2:26 PM d4v3y_5c0n3s  wrote:
>
>> So, I'm trying to implement the following hash function:
>> fn hash {n:int | n > 0}
>> ( s: string(n), size: int(n) ) : [o:int | o >= 0; o < n] int o = let
>> fun hash_num {i:nat | i <= n}
>> ( i: int i, h: int ) : int =
>> if i < size then let
>> val c_at_i = string_get_at_gint(s, i)
>> in
>> hash_num(i+1, h * 101 + g0int_of_char(c_at_i))
>> end else h
>> in
>> abs( hash_num(0, 0) ) % size
>> end
>>
>> Which produces the following error message:
>> /home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) 
>> -- 409(line=21, offs=30): error(3): the dynamic expression cannot be 
>> assigned the type [S2Eexi(o(8727); S2Eapp(S2Ecst(>=); S2Evar(o(8727)), 
>> S2Eintinf(0)), S2Eapp(S2Ecst(<); S2Evar(o(8727)), S2Evar(n(8725))); 
>> S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), S2Evar(o(8727].
>> /home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) 
>> -- 409(line=21, offs=30): error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
>> S2Eextkind(atstype_int), S2EVar(5314))
>> /home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) 
>> -- 409(line=21, offs=30): error(3): mismatch of static terms (tyleq):
>> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
>> The needed term is: S2Eexi(o(8727); S2Eapp(S2Ecst(>=); S2Evar(o(8727)), 
>> S2Eintinf(0)), S2Eapp(S2Ecst(<); S2Evar(o(8727)), S2Evar(n(8725))); 
>> S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), S2Evar(o(8727
>>
>> My question is, how do I tell the typechecker that this code works 
>> fine?  The abs() ensures that the result is positive, and the '%' (modulo) 
>> operation will always return positive/zero because neither input can be 
>> negative.  Is there some way that I can express this to the typechecker?  
>> Did I make a mistake in my code that I missed?
>> Based on the info that I can find, I think the solution to my problem 
>> either relies on the use of the '#[ | ]' syntax, or the 'praxi' keyword, 
>> but I'm not fully clear on how either work/when to use them.  Any help is 
>> appreciated, and if the issue seems connected to code that I didn't show 
>> here, please let me know and I will be happy to provide more source code.
>>
>> -- 
>> 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/99521a07-3fc9-4607-bdc3-e347c83d9531n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/99521a07-3fc9-4607-bdc3-e347c83d9531n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/3751b740-fdab-459c-8175-62b17f72085en%40googlegroups.com.


How do I work around the limitations of the typechecker?

2020-12-23 Thread d4v3y_5c0n3s
So, I'm trying to implement the following hash function:
fn hash {n:int | n > 0}
( s: string(n), size: int(n) ) : [o:int | o >= 0; o < n] int o = let
fun hash_num {i:nat | i <= n}
( i: int i, h: int ) : int =
if i < size then let
val c_at_i = string_get_at_gint(s, i)
in
hash_num(i+1, h * 101 + g0int_of_char(c_at_i))
end else h
in
abs( hash_num(0, 0) ) % size
end

Which produces the following error message:
/home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) -- 
409(line=21, offs=30): error(3): the dynamic expression cannot be assigned 
the type [S2Eexi(o(8727); S2Eapp(S2Ecst(>=); S2Evar(o(8727)), 
S2Eintinf(0)), S2Eapp(S2Ecst(<); S2Evar(o(8727)), S2Evar(n(8725))); 
S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), S2Evar(o(8727].
/home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) -- 
409(line=21, offs=30): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2EVar(5314))
/home/tmj90/Goldelish-Engine/source/data/dict.dats: 381(line=21, offs=2) -- 
409(line=21, offs=30): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
The needed term is: S2Eexi(o(8727); S2Eapp(S2Ecst(>=); S2Evar(o(8727)), 
S2Eintinf(0)), S2Eapp(S2Ecst(<); S2Evar(o(8727)), S2Evar(n(8725))); 
S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), S2Evar(o(8727

My question is, how do I tell the typechecker that this code works 
fine?  The abs() ensures that the result is positive, and the '%' (modulo) 
operation will always return positive/zero because neither input can be 
negative.  Is there some way that I can express this to the typechecker?  
Did I make a mistake in my code that I missed?
Based on the info that I can find, I think the solution to my problem 
either relies on the use of the '#[ | ]' syntax, or the 'praxi' keyword, 
but I'm not fully clear on how either work/when to use them.  Any help is 
appreciated, and if the issue seems connected to code that I didn't show 
here, please let me know and I will be happy to provide more source code.

-- 
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/99521a07-3fc9-4607-bdc3-e347c83d9531n%40googlegroups.com.


Re: Can arrayptr_freelin() cause a memory leak?

2020-12-15 Thread d4v3y_5c0n3s
That honestly sounds amazing!  I had no idea ATS3's improved template 
support would be capable of something as powerful as that.  Thanks, and 
keep up the great work! :)

On Tuesday, December 15, 2020 at 12:34:55 PM UTC-5 gmhwxi wrote:

> >>Okay, so what you are saying is that in order for the code to compile, I 
> will need to implement the template for the given type.
>
> That's right.
>
> Hopefully, such a template can be automatically generated in ATS3 based on 
> the given (or inferred) type
> information. There should be a substantial component in ATS3 to support 
> this kind of type-based meta-programming.
>
> On Tue, Dec 15, 2020 at 11:43 AM d4v3y_5c0n3s  wrote:
>
>> Okay, so what you are saying is that in order for the code to compile, I 
>> will need to implement the template for the given type.  That makes sense, 
>> thanks for the explanation! :)
>>
>> On Tuesday, December 15, 2020 at 10:57:09 AM UTC-5 gmhwxi wrote:
>>
>>> It should not as arrayptr_freelin calls array_uninitize$clear to free 
>>> all the stored elements.
>>> It is your obligation to implement the latter.
>>>
>>>
>>> On Tue, Dec 15, 2020 at 9:54 AM d4v3y_5c0n3s  wrote:
>>>
>>>> I just have a question about using arrayptr_freelin() (which frees 
>>>> an arrayptr that contains a vt@ype.)  I have an arrayptr which contains 
>>>> datavtypes, and these datavtypes act like a list in that they can contain 
>>>> a 
>>>> reference to another of the same datavtype.  The typechecker lets me 
>>>> simply 
>>>> call arrayptr_freelin() on the arrayptr, but does this cause a memory 
>>>> leak?  Do I need to free the individual datavtypes first?
>>>> I can provide a code example if anyone reading this doesn't 
>>>> understand what I am talking about.  The types and functions that I am 
>>>> using are all in the prelude.
>>>>
>>>> -- 
>>>> 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/84121c93-a043-405c-be86-e7cc74903f68n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/84121c93-a043-405c-be86-e7cc74903f68n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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/b6d0bb1a-cfa2-4c1d-aca5-3d669d827016n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/b6d0bb1a-cfa2-4c1d-aca5-3d669d827016n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/108e4197-5274-43cc-9a00-dbe7efc35e66n%40googlegroups.com.


Re: Can arrayptr_freelin() cause a memory leak?

2020-12-15 Thread d4v3y_5c0n3s
Okay, so what you are saying is that in order for the code to compile, I 
will need to implement the template for the given type.  That makes sense, 
thanks for the explanation! :)

On Tuesday, December 15, 2020 at 10:57:09 AM UTC-5 gmhwxi wrote:

> It should not as arrayptr_freelin calls array_uninitize$clear to free all 
> the stored elements.
> It is your obligation to implement the latter.
>
>
> On Tue, Dec 15, 2020 at 9:54 AM d4v3y_5c0n3s  wrote:
>
>> I just have a question about using arrayptr_freelin() (which frees an 
>> arrayptr that contains a vt@ype.)  I have an arrayptr which contains 
>> datavtypes, and these datavtypes act like a list in that they can contain a 
>> reference to another of the same datavtype.  The typechecker lets me simply 
>> call arrayptr_freelin() on the arrayptr, but does this cause a memory 
>> leak?  Do I need to free the individual datavtypes first?
>> I can provide a code example if anyone reading this doesn't 
>> understand what I am talking about.  The types and functions that I am 
>> using are all in the prelude.
>>
>> -- 
>> 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/84121c93-a043-405c-be86-e7cc74903f68n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/84121c93-a043-405c-be86-e7cc74903f68n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/b6d0bb1a-cfa2-4c1d-aca5-3d669d827016n%40googlegroups.com.


Can arrayptr_freelin() cause a memory leak?

2020-12-15 Thread d4v3y_5c0n3s
I just have a question about using arrayptr_freelin() (which frees an 
arrayptr that contains a vt@ype.)  I have an arrayptr which contains 
datavtypes, and these datavtypes act like a list in that they can contain a 
reference to another of the same datavtype.  The typechecker lets me simply 
call arrayptr_freelin() on the arrayptr, but does this cause a memory 
leak?  Do I need to free the individual datavtypes first?
I can provide a code example if anyone reading this doesn't understand 
what I am talking about.  The types and functions that I am using are all 
in the prelude.

-- 
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/84121c93-a043-405c-be86-e7cc74903f68n%40googlegroups.com.


Re: Current Status of ATS3 (2020-11-22)

2020-11-25 Thread d4v3y_5c0n3s
Thanks for the reply! :)

On Tuesday, November 24, 2020 at 1:36:31 AM UTC-5 gmhwxi wrote:

>
> >> *will this change affect the execution speed of ATS3 code compared to 
> ATS2?* 
>
> The short answer is no. If anything, I would bet that ATS3 code should run 
> faster :)
> I will strive to structure the compiler in a way that should be easy for 
> others to contribute.
>
> On Monday, November 23, 2020 at 11:20:59 PM UTC-5 d4v3y_5c0n3s wrote:
>
>> Thanks for the update, Hongwei.  It's really awesome to hear about the 
>> progress being made on ATS3!  I have a question I'd like to ask about 
>> ATS3's compilation.  You mentioned that rather than compiling ATS code 
>> straight into a C file, that ATS3 first compiles it into XATSCML, and in 
>> the future into XATSCL0.  You said this was to make it easier to compile 
>> ATS into languages other than C, which is awesome and I can definitely 
>> appreciate that.  My question is, *will this change affect the execution 
>> speed of ATS3 code compared to ATS2?*  I ask because I am currently 
>> working on building a game engine in ATS, and so performance is very 
>> important to my use case.  If ATS3 could potentially be slower than ATS2 
>> was, please let me know, I'd be willing to try and contribute to the 
>> project to improve this aspect.
>> Thanks, and good luck with ATS3.
>>
>> On Sunday, November 22, 2020 at 9:31:16 AM UTC-5 gmhwxi wrote:
>>
>>>
>>>
>>> Hi, there, 
>>>
>>> HX-2020-11-22: 
>>>
>>> (* 
>>> HX-2018-04-07: Let us get started!!! 
>>> *) 
>>>
>>> As of today, I am pleased to announce that ATS3 has reached a stage 
>>> where it can be realistically used in software construction. This is 
>>> achieved after slightly more than two and one-half years of continual 
>>> development by yours truly :) 
>>>
>>> ## 
>>> # 
>>> # The current status 
>>> # 
>>> ## 
>>>
>>> XATSOPT: 
>>>
>>> Xatsopt is a functioning compiler implemented in ATS2 for translating 
>>> ATS3 into a typed intermediate language of the name XATSCML, which is 
>>> both C-like and ML-like. It is planned for xatsopt to further 
>>> translate XATSCML into XATSCL0, a low-level C-like language. I now 
>>> primarily see xatsopt as a library (libxatsopt) for implementing tools 
>>> to support programming with ATS3. 
>>>
>>> XATS2JS: 
>>>
>>> Xats2js is a functioning compiler implemented in ATS2 for translating 
>>> XATSCML into JavaScript (or JS for short). It should be noted that 
>>> xats2js can compile tail-recursive calls into local jumps, effectively 
>>> supporting the common practice in functional programming of writing 
>>> loops as tail-recursive functions. 
>>>
>>> I will give detailed explanation elsewhere on using xats2js. Generally 
>>> speaking, one can now practice a form of co-programming with ATS3 and 
>>> JS. The JS code generated by xats2js from compiling ATS3 source can be 
>>> directly combined with other JS code (as if the generated code were 
>>> manually written in JS) 
>>>
>>> ## 
>>> # 
>>> # Future Development 
>>> # 
>>> ## 
>>>
>>> Documenting Xatsopt: 
>>>
>>> This has been assigned a high priority. It is hoped that other 
>>> people interested in ATS3 can start developing tools for ATS3 after 
>>> a minimal amount of documentation on xatsopt is made available. 
>>>
>>> Advanced Type-Checking: 
>>>
>>> While one can specify with linear types and dependent types in ATS3, 
>>> there is no type-checking for such advanced types in xatsopt. I plan 
>>> to concentrate on implementing support for such type-checking in the 
>>> next phase of ATS3 development. 
>>>
>>> ## 
>>> # 
>>> # A little history of ATS3 
>>> # 
>>> ## 
>>>
>>> Essentially, ATS3 refers to the third edition of ATS, and ATS/Xanadu 
>>> is currently the only implementation of ATS3. Note that the names ATS3 
>>> and ATS/Xanadu are often used interchangeably. 
>>>
>>> In the ATS family of languages, the first implementation is named 
>>> ATS/Proto (2004) and the language it implements is referred to as 
>>> ATS0. Please note that the implementation of ATS/Proto is written in 
>>> OCaml. The next implementation is ATS/Geizella (2007), whi

Re: Current Status of ATS3 (2020-11-22)

2020-11-23 Thread d4v3y_5c0n3s
Thanks for the update, Hongwei.  It's really awesome to hear about the 
progress being made on ATS3!  I have a question I'd like to ask about 
ATS3's compilation.  You mentioned that rather than compiling ATS code 
straight into a C file, that ATS3 first compiles it into XATSCML, and in 
the future into XATSCL0.  You said this was to make it easier to compile 
ATS into languages other than C, which is awesome and I can definitely 
appreciate that.  My question is, *will this change affect the execution 
speed of ATS3 code compared to ATS2?*  I ask because I am currently working 
on building a game engine in ATS, and so performance is very important to 
my use case.  If ATS3 could potentially be slower than ATS2 was, please let 
me know, I'd be willing to try and contribute to the project to improve 
this aspect.
Thanks, and good luck with ATS3.

On Sunday, November 22, 2020 at 9:31:16 AM UTC-5 gmhwxi wrote:

>
>
> Hi, there, 
>
> HX-2020-11-22: 
>
> (* 
> HX-2018-04-07: Let us get started!!! 
> *) 
>
> As of today, I am pleased to announce that ATS3 has reached a stage 
> where it can be realistically used in software construction. This is 
> achieved after slightly more than two and one-half years of continual 
> development by yours truly :) 
>
> ## 
> # 
> # The current status 
> # 
> ## 
>
> XATSOPT: 
>
> Xatsopt is a functioning compiler implemented in ATS2 for translating 
> ATS3 into a typed intermediate language of the name XATSCML, which is 
> both C-like and ML-like. It is planned for xatsopt to further 
> translate XATSCML into XATSCL0, a low-level C-like language. I now 
> primarily see xatsopt as a library (libxatsopt) for implementing tools 
> to support programming with ATS3. 
>
> XATS2JS: 
>
> Xats2js is a functioning compiler implemented in ATS2 for translating 
> XATSCML into JavaScript (or JS for short). It should be noted that 
> xats2js can compile tail-recursive calls into local jumps, effectively 
> supporting the common practice in functional programming of writing 
> loops as tail-recursive functions. 
>
> I will give detailed explanation elsewhere on using xats2js. Generally 
> speaking, one can now practice a form of co-programming with ATS3 and 
> JS. The JS code generated by xats2js from compiling ATS3 source can be 
> directly combined with other JS code (as if the generated code were 
> manually written in JS) 
>
> ## 
> # 
> # Future Development 
> # 
> ## 
>
> Documenting Xatsopt: 
>
> This has been assigned a high priority. It is hoped that other 
> people interested in ATS3 can start developing tools for ATS3 after 
> a minimal amount of documentation on xatsopt is made available. 
>
> Advanced Type-Checking: 
>
> While one can specify with linear types and dependent types in ATS3, 
> there is no type-checking for such advanced types in xatsopt. I plan 
> to concentrate on implementing support for such type-checking in the 
> next phase of ATS3 development. 
>
> ## 
> # 
> # A little history of ATS3 
> # 
> ## 
>
> Essentially, ATS3 refers to the third edition of ATS, and ATS/Xanadu 
> is currently the only implementation of ATS3. Note that the names ATS3 
> and ATS/Xanadu are often used interchangeably. 
>
> In the ATS family of languages, the first implementation is named 
> ATS/Proto (2004) and the language it implements is referred to as 
> ATS0. Please note that the implementation of ATS/Proto is written in 
> OCaml. The next implementation is ATS/Geizella (2007), which is also 
> written in OCaml. And the language implemented by ATS/Geizella is 
> referred to as ATS1. ATS/Anairiats (2008) is an implementation of ATS1 
> in itself; the implementation is first compiled by ATS/Geizella and 
> then by itself, succeeding in so-called bootstrapping. The next 
> edition of ATS is ATS2, which is given an implementation of the name 
> ATS/Postiats (2013) written in ATS1. 
>
> ATS/Xanadu implements ATS3 and the implementation is written in ATS2. 
> While there is currently no plan to bootstrap ATS3 by implementing it 
> in itself, it is perceivable that ATS/Xanadu can be readily translated 
> (manually) into such an implementation since the difference between 
> ATS2 and ATS3 in terms of both syntax and semantics is fairly minor 
> (for the part being used in compiler implementation). 
>
> ## 
>
> Cheers! 
>
> --Hongwei 
>
> ## 
>
> For previously post messages: 
>
> https://github.com/githwxi/ATS-Xanadu/tree/master/docgen/NOTES 
> ##
>
>
>

-- 
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/c2bbf

Re: Accessing the contents of a pointer(pointing to a linear type) within a record

2020-11-03 Thread d4v3y_5c0n3s
So, I found the issue with my code.  Here is a version of my previous code 
which passes type checking:

   - 
   - vtypedef pointer_in_rec(a:vt@ype) = [l:addr] @{ pointer=(a @ l, 
   mfree_gc_v(l) | ptr l) }
   - vtypedef pointer_in_rec2(a:vt@ype) = [l:addr] @{ pointer=(unit_p, 
   unit_p | ptr l) }
   - 
   - fn{a:vt@ype} get_pointer_in_rec ( x: !pointer_in_rec(a) >> 
   pointer_in_rec2(a)): a = let
   - val (pfat, pfgc | p) = x.pointer
   - val ret = !p
   - val () = ptr_free(pfgc, pfat | p)
   - in
   - ret
   - end

I originally got this working with t@ype, but then I found that it also 
worked with vt@ype.  I don't know if this makes a difference, since Artyom 
said that the function duplicates the value it gets by dereferencing the 
pointer.  I should test this more in the future, but for now I've provided 
my working solution.

Thanks, Artyom!  You're awesome!  :)

On Monday, November 2, 2020 at 11:23:07 PM UTC-5 d4v3y_5c0n3s wrote:

> Thanks for the reply, I really appreciate the help.  I'll try this 
> suggestion out tomorrow.  One question though: if I use the t@ype sort, can 
> I still store a vt@ype within the pointer?
>
> On Monday, November 2, 2020 at 3:24:09 PM UTC-5 artyom.s...@gmail.com 
> wrote:
>
>>
>> 2 лист. 2020 р. о 20:40 d4v3y_5c0n3s  пише:
>>
>> Hey, so, I'm trying to figure out how to make an accessor to a type that 
>> I've created in a personal project.  The type resembles the following:
>>
>>
>>- vtypedef pointer_in_rec = [a:vt@ype][l:addr] @{ pointer=(a @ l, 
>>mfree_gc_v(l) | ptr l) }
>>
>> I think that [a] should be a type parameter:
>>
>> vtypedef pointer_in_rec (a: t@ype) = [l:addr] (a @ l, mfree_gc_v l | ptr 
>> l)
>>
>> What I'm trying to do, is create a function which takes in the type 
>> "pointer_in_rec" via call-by-value, and returns the vt@ype that is stored 
>> at the pointer position.  My current function interface for doing so is as 
>> follows:
>>
>>- fn{a:vt@ype} get_pointer_in_rec ( x: !pointer_in_rec ): a
>>
>> The above becomes:
>>
>> fun{a:t@ype} get_pointer_in_rec (x: !pointer_in_rec(a)): a
>>
>> The type [a] should be non-linear, since the function duplicates the 
>> value it gets by dereferencing the pointer.
>>
>> I've been experimenting for a while, and I've yet to find an example of 
>> this online.  Please let me know if you have any questions, and I'll post 
>> any updates or things I discover.  Thank you, I truly appreciate any help 
>> that can be given.
>>
>> -- 
>> 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/b47371b1-b316-4614-8783-9a090245eba7n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/b47371b1-b316-4614-8783-9a090245eba7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
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/a80e5763-ff84-4d64-84e9-170dc6a3df1fn%40googlegroups.com.


Re: Accessing the contents of a pointer(pointing to a linear type) within a record

2020-11-02 Thread d4v3y_5c0n3s
Thanks for the reply, I really appreciate the help.  I'll try this 
suggestion out tomorrow.  One question though: if I use the t@ype sort, can 
I still store a vt@ype within the pointer?

On Monday, November 2, 2020 at 3:24:09 PM UTC-5 artyom.s...@gmail.com wrote:

>
> 2 лист. 2020 р. о 20:40 d4v3y_5c0n3s  пише:
>
> Hey, so, I'm trying to figure out how to make an accessor to a type that 
> I've created in a personal project.  The type resembles the following:
>
>
>- vtypedef pointer_in_rec = [a:vt@ype][l:addr] @{ pointer=(a @ l, 
>mfree_gc_v(l) | ptr l) }
>
> I think that [a] should be a type parameter:
>
> vtypedef pointer_in_rec (a: t@ype) = [l:addr] (a @ l, mfree_gc_v l | ptr l)
>
> What I'm trying to do, is create a function which takes in the type 
> "pointer_in_rec" via call-by-value, and returns the vt@ype that is stored 
> at the pointer position.  My current function interface for doing so is as 
> follows:
>
>- fn{a:vt@ype} get_pointer_in_rec ( x: !pointer_in_rec ): a
>
> The above becomes:
>
> fun{a:t@ype} get_pointer_in_rec (x: !pointer_in_rec(a)): a
>
> The type [a] should be non-linear, since the function duplicates the value 
> it gets by dereferencing the pointer.
>
> I've been experimenting for a while, and I've yet to find an example of 
> this online.  Please let me know if you have any questions, and I'll post 
> any updates or things I discover.  Thank you, I truly appreciate any help 
> that can be given.
>
> -- 
> 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/b47371b1-b316-4614-8783-9a090245eba7n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ats-lang-users/b47371b1-b316-4614-8783-9a090245eba7n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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/341f7d91-955b-4d7c-85c6-2537537797fan%40googlegroups.com.


Accessing the contents of a pointer(pointing to a linear type) within a record

2020-11-02 Thread d4v3y_5c0n3s
Hey, so, I'm trying to figure out how to make an accessor to a type that 
I've created in a personal project.  The type resembles the following:

   - vtypedef pointer_in_rec = [a:vt@ype][l:addr] @{ pointer=(a @ l, 
   mfree_gc_v(l) | ptr l) }

What I'm trying to do, is create a function which takes in the type 
"pointer_in_rec" via call-by-value, and returns the vt@ype that is stored 
at the pointer position.  My current function interface for doing so is as 
follows:

   - fn{a:vt@ype} get_pointer_in_rec ( x: !pointer_in_rec ): a

I've been experimenting for a while, and I've yet to find an example of 
this online.  Please let me know if you have any questions, and I'll post 
any updates or things I discover.  Thank you, I truly appreciate any help 
that can be given.

-- 
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/b47371b1-b316-4614-8783-9a090245eba7n%40googlegroups.com.


Re: The current status of ATS3

2020-11-02 Thread d4v3y_5c0n3s
Thanks for the update!  I've still got much to learn about ATS2, but ATS3 
has got me very excited.  I'll check out the Github page, perhaps I could 
help the project by doing some tests or the like.  Please post if you could 
use some help on anything.

On Sunday, November 1, 2020 at 9:42:19 AM UTC-5 gmhwxi wrote:

> Hi,
>
> I would like to give you a quick report on the current status of ATS3.
> I spent most of my time working on xatsopt and xats2js in the past two 
> months.
>
> What is Xatsopt?
>
> Xatsopt is a compiler that translates source code in ATS3 into a target 
> language
> called the ATSCML that is both C-like and ML-like. The key steps in this 
> translation
> include type inference (of Hindley-style) and template resolution.
>
> What is Xats2js?
>
> Xats2js is a compiler that translates from ATSCML to JavaScript. 
> Currently, xats2js
> translates directly without performing optimizations. In particular, there 
> is no optimization for handling tail-recursive calls. Xats2js is 
> functioning and I myself am using it for some of my own work. Here is the 
> github repo for xats2js:
>
> https://github.com/xanadu-lang/xats2js
>
> If you git-clone the repo, you can play with xats2js in the following 
> directory:
>
> https://github.com/xanadu-lang/xats2js/tree/master/docgen/pground
>
> Cheers!
>
> --Hongwei
>
>

-- 
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/a1d84c8f-95a7-49e1-8936-5c73a0f50332n%40googlegroups.com.


Re: Strange mismatch of equal terms

2020-10-12 Thread d4v3y_5c0n3s
The thread you linked me answered my problem perfectly.  Thanks, you are 
awesome!

On Monday, October 12, 2020 at 6:31:14 AM UTC-4 d4v3y_5c0n3s wrote:

> Thanks Ice, I thought that something may have been posted about this, but 
> I wasn't sure what to search for.  I'll check this out and post whether 
> this works or not.  But seriously, thank you!
>
> On Monday, October 12, 2020 at 4:02:55 AM UTC-4 ice.r...@gmail.com wrote:
>
>> or, in case if this URL is not reachable (seems like relative to my 
>> mailbox):
>> https://groups.google.com/g/ats-lang-users/c/V5LihCmnXKc
>>
>> пн, 12 окт. 2020 г. в 08:01, Dambaev Alexander :
>>
>>> Hi,
>>>
>>> check this topic:
>>>
>>> https://mail.google.com/mail/u/0/#category/forums/QgrcJHsBrnXTtpBcBJPBCfzSNNVXkQVSFQv
>>>
>>> пн, 12 окт. 2020 г. в 02:16, d4v3y_5c0n3s :
>>>
>>>> Here's my problem:
>>>> I'm encountering this weird error where the compiler is for some reason 
>>>> telling me that I cannot produce an "asset_hndl" record type because it 
>>>> expects a "fpath" type and I gave an "fpath" type.  I'm really baffled by 
>>>> this, any help is appreciated.
>>>>
>>>> Here's my code:
>>>> assume asset_hndl = [a:vtype] @{ path=fpath, asset_ptr=a, 
>>>> timestamp=usint }
>>>> assume fpath = Strptr1
>>>> assume path_variable = @{ variable=fpath, mapping=fpath }
>>>>
>>>> fun P ( path: string ) : fpath = "sta#"
>>>> fun asset_map_filename ( filename: fpath, pv: !path_variable ) : fpath 
>>>> = "sta#"
>>>> fun{a:vtype} asset_hndl_new ( path: !fpath, pv: !path_variable ) : 
>>>> asset_hndl = "sta#"
>>>>
>>>> implement{a} asset_hndl_new ( path, pv ) = 
>>>> (@{path=asset_map_filename(path, 
>>>> pv), asset_ptr=the_null_ptr, timestamp=int_to_usint(0)}:asset_hndl)
>>>>
>>>> Here's the error:
>>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_asset.dats
>>>> /home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, 
>>>> offs=45) -- 738(line=28, offs=132): error(3): the dynamic expression 
>>>> cannot 
>>>> be assigned the type [S2Eexi(a(8761); ; S2Etyrec(flt0; npf=-1; 
>>>> path=S2Ecst(fpath), asset_ptr=S2Evar(a(8761)), timestamp=S2Ecst(usint)))].
>>>> /home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, 
>>>> offs=45) -- 738(line=28, offs=132): error(3): mismatch of static terms 
>>>> (tyleq):
>>>> The actual term is: S2Ecst(fpath)
>>>> The needed term is: S2Ecst(fpath)
>>>>
>>>> Let me know if you need any more information.
>>>>
>>>> -- 
>>>> 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/9c6a2031-519d-4ea7-8d45-dd66cb38dc7fn%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/9c6a2031-519d-4ea7-8d45-dd66cb38dc7fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
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/9088779f-2fc2-4084-85b2-5e3fd77d8fd0n%40googlegroups.com.


Re: Strange mismatch of equal terms

2020-10-12 Thread d4v3y_5c0n3s
Thanks Ice, I thought that something may have been posted about this, but I 
wasn't sure what to search for.  I'll check this out and post whether this 
works or not.  But seriously, thank you!

On Monday, October 12, 2020 at 4:02:55 AM UTC-4 ice.r...@gmail.com wrote:

> or, in case if this URL is not reachable (seems like relative to my 
> mailbox):
> https://groups.google.com/g/ats-lang-users/c/V5LihCmnXKc
>
> пн, 12 окт. 2020 г. в 08:01, Dambaev Alexander :
>
>> Hi,
>>
>> check this topic:
>>
>> https://mail.google.com/mail/u/0/#category/forums/QgrcJHsBrnXTtpBcBJPBCfzSNNVXkQVSFQv
>>
>> пн, 12 окт. 2020 г. в 02:16, d4v3y_5c0n3s :
>>
>>> Here's my problem:
>>> I'm encountering this weird error where the compiler is for some reason 
>>> telling me that I cannot produce an "asset_hndl" record type because it 
>>> expects a "fpath" type and I gave an "fpath" type.  I'm really baffled by 
>>> this, any help is appreciated.
>>>
>>> Here's my code:
>>> assume asset_hndl = [a:vtype] @{ path=fpath, asset_ptr=a, 
>>> timestamp=usint }
>>> assume fpath = Strptr1
>>> assume path_variable = @{ variable=fpath, mapping=fpath }
>>>
>>> fun P ( path: string ) : fpath = "sta#"
>>> fun asset_map_filename ( filename: fpath, pv: !path_variable ) : fpath = 
>>> "sta#"
>>> fun{a:vtype} asset_hndl_new ( path: !fpath, pv: !path_variable ) : 
>>> asset_hndl = "sta#"
>>>
>>> implement{a} asset_hndl_new ( path, pv ) = (@{path=asset_map_filename(path, 
>>> pv), asset_ptr=the_null_ptr, timestamp=int_to_usint(0)}:asset_hndl)
>>>
>>> Here's the error:
>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_asset.dats
>>> /home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, offs=45) 
>>> -- 738(line=28, offs=132): error(3): the dynamic expression cannot be 
>>> assigned the type [S2Eexi(a(8761); ; S2Etyrec(flt0; npf=-1; 
>>> path=S2Ecst(fpath), asset_ptr=S2Evar(a(8761)), timestamp=S2Ecst(usint)))].
>>> /home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, offs=45) 
>>> -- 738(line=28, offs=132): error(3): mismatch of static terms (tyleq):
>>> The actual term is: S2Ecst(fpath)
>>> The needed term is: S2Ecst(fpath)
>>>
>>> Let me know if you need any more information.
>>>
>>> -- 
>>> 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/9c6a2031-519d-4ea7-8d45-dd66cb38dc7fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ats-lang-users/9c6a2031-519d-4ea7-8d45-dd66cb38dc7fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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/8401fd42-2773-44d8-83ec-1834c673dd53n%40googlegroups.com.


Strange mismatch of equal terms

2020-10-11 Thread d4v3y_5c0n3s
Here's my problem:
I'm encountering this weird error where the compiler is for some reason 
telling me that I cannot produce an "asset_hndl" record type because it 
expects a "fpath" type and I gave an "fpath" type.  I'm really baffled by 
this, any help is appreciated.

Here's my code:
assume asset_hndl = [a:vtype] @{ path=fpath, asset_ptr=a, timestamp=usint }
assume fpath = Strptr1
assume path_variable = @{ variable=fpath, mapping=fpath }

fun P ( path: string ) : fpath = "sta#"
fun asset_map_filename ( filename: fpath, pv: !path_variable ) : fpath = 
"sta#"
fun{a:vtype} asset_hndl_new ( path: !fpath, pv: !path_variable ) : 
asset_hndl = "sta#"

implement{a} asset_hndl_new ( path, pv ) = (@{path=asset_map_filename(path, 
pv), asset_ptr=the_null_ptr, timestamp=int_to_usint(0)}:asset_hndl)

Here's the error:
patscc -tcats /home/tmj90/Goldelish-Engine/source/g_asset.dats
/home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, offs=45) -- 
738(line=28, offs=132): error(3): the dynamic expression cannot be assigned 
the type [S2Eexi(a(8761); ; S2Etyrec(flt0; npf=-1; path=S2Ecst(fpath), 
asset_ptr=S2Evar(a(8761)), timestamp=S2Ecst(usint)))].
/home/tmj90/Goldelish-Engine/source/g_asset.dats: 651(line=28, offs=45) -- 
738(line=28, offs=132): error(3): mismatch of static terms (tyleq):
The actual term is: S2Ecst(fpath)
The needed term is: S2Ecst(fpath)

Let me know if you need any more information.

-- 
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/9c6a2031-519d-4ea7-8d45-dd66cb38dc7fn%40googlegroups.com.


Re: How do I store a viewtype in an array and then access that value?

2020-09-29 Thread d4v3y_5c0n3s
I found the answer by looking at some of the code in the ATS github repo.  
Here's the working code:
implement model_print ( m ) = let
  fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
  ( i: int i, ar: !arrayptr(mesh, l, j)): void =
  if i >= 0 then let
val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar)
val (ari_pf, ari_fpf | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
size_of_int(i))
val () = mesh_print(!ar_i)
prval () = pf_ar := ari_fpf(ari_pf)
prval () = arrayptr_addback(pf_ar | ar)
  in
mesh_print_loop(i-1, ar)
  end else ()
in
  mesh_print_loop((m.0)-1, m.1)
end

On Sunday, September 27, 2020 at 9:09:23 PM UTC-4 d4v3y_5c0n3s wrote:

> Also, as a side note, I noticed that the "array_ptr_takeout()" function 
> calls the array_v_takeout() proof function, but why is there no 
> array_v_addback()?
>
> On Sunday, September 27, 2020 at 5:13:32 PM UTC-4 d4v3y_5c0n3s wrote:
>
>> Ice, thank you for your suggestion, once I get this working I should 
>> replace my handmade loops with arrayptr_foreach() calls like you suggested.
>> Artyom, I see what you were trying to do with your suggestion, but it 
>> didn't work due to the proof pf_ar being consumed by the 
>> array_ptr_takeout() call.
>>
>> Here is the code for anyone who wants to see it:
>> implement model_print ( m ) = let
>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>   if i >= 0 then let
>> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar)
>> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
>> size_of_int(i))
>> val () = mesh_print(!ar_i)
>> prval () = arrayptr_addback(pf_ar | ar_p)
>>   in
>> mesh_print_loop(i-1, ar)
>>   end else ()
>> in
>>   mesh_print_loop((m.0)-1, m.1)
>> end
>>
>> Here is the error message from the compiler:
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
>> offs=33) -- 79158(line=2750, offs=38): error(3): the linear dynamic 
>> variable [pf_ar$5913(-1)] is no longer available.
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
>> offs=33) -- 79158(line=2750, offs=38): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eat(S2Etyarr(S2Einvar(S2EVar(7937)); 
>> S2EVar(7939)), S2EVar(7938))].
>>
>> I will continue to work on this, and I'll post if I come to a solution.
>> On Saturday, September 26, 2020 at 12:10:11 PM UTC-4 d4v3y_5c0n3s wrote:
>>
>>> Awesome!  Thanks for all of these suggestions!  I'll try them later on 
>>> and then post how it went.
>>>
>>> On Saturday, September 26, 2020 at 10:56:07 AM UTC-4 
>>> artyom.s...@gmail.com wrote:
>>>
>>>> Hi d4v3y,
>>>>
>>>> I will make a fix below that might work. However, as Alexander 
>>>> mentioned, if you only want to map an array (i.e. apply a function to each 
>>>> element), then you probably don't want to hand-roll a loop.
>>>>
>>>> сб, 26 сент. 2020 г. в 16:54, d4v3y_5c0n3s :
>>>>
>>>>> So, I tried to call the prelude's array_ptr_takeout() function, but 
>>>>> that only works with a pointer of view array_v(), wereas I am using the 
>>>>> arrayptr() viewtype.  To solve this, I called the cast function 
>>>>> arrayptr_takeout_viewptr(), which seemed to suit my needs perfectly.  
>>>>> Here's my code currently:
>>>>
>>>> implement model_print ( m ) = let
>>>>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>>>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>>>>   if i >= 0 then let
>>>>>
>>>> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar) // take out the 
>>>>> view: the type of [ar] is changed!
>>>>>
>>>> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
>>>>> size_of_int(i))
>>>>>
>>>> val () = mesh_print(!ar_i) 
>>>> prval () = arrayptr_addback (pf_ar | ar) // put it back where 
>>>> it belongs: [ar] is now the same type as it was on entry
>>>>
>>>>>   in
>>>>>
>>>> mesh_print_loop(i-1, ar)
>>>>>   end else ()
>>>>> in
>>>>>   mesh_print_loop((m.0)-1, m.1)
>>>>> end
>>>>>
>>>>
>

Re: How do I store a viewtype in an array and then access that value?

2020-09-27 Thread d4v3y_5c0n3s
Also, as a side note, I noticed that the "array_ptr_takeout()" function 
calls the array_v_takeout() proof function, but why is there no 
array_v_addback()?

On Sunday, September 27, 2020 at 5:13:32 PM UTC-4 d4v3y_5c0n3s wrote:

> Ice, thank you for your suggestion, once I get this working I should 
> replace my handmade loops with arrayptr_foreach() calls like you suggested.
> Artyom, I see what you were trying to do with your suggestion, but it 
> didn't work due to the proof pf_ar being consumed by the 
> array_ptr_takeout() call.
>
> Here is the code for anyone who wants to see it:
> implement model_print ( m ) = let
>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>   if i >= 0 then let
> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar)
> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
> size_of_int(i))
> val () = mesh_print(!ar_i)
> prval () = arrayptr_addback(pf_ar | ar_p)
>   in
> mesh_print_loop(i-1, ar)
>   end else ()
> in
>   mesh_print_loop((m.0)-1, m.1)
> end
>
> Here is the error message from the compiler:
> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
> offs=33) -- 79158(line=2750, offs=38): error(3): the linear dynamic 
> variable [pf_ar$5913(-1)] is no longer available.
> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
> offs=33) -- 79158(line=2750, offs=38): error(3): the dynamic expression 
> cannot be assigned the type [S2Eat(S2Etyarr(S2Einvar(S2EVar(7937)); 
> S2EVar(7939)), S2EVar(7938))].
>
> I will continue to work on this, and I'll post if I come to a solution.
> On Saturday, September 26, 2020 at 12:10:11 PM UTC-4 d4v3y_5c0n3s wrote:
>
>> Awesome!  Thanks for all of these suggestions!  I'll try them later on 
>> and then post how it went.
>>
>> On Saturday, September 26, 2020 at 10:56:07 AM UTC-4 
>> artyom.s...@gmail.com wrote:
>>
>>> Hi d4v3y,
>>>
>>> I will make a fix below that might work. However, as Alexander 
>>> mentioned, if you only want to map an array (i.e. apply a function to each 
>>> element), then you probably don't want to hand-roll a loop.
>>>
>>> сб, 26 сент. 2020 г. в 16:54, d4v3y_5c0n3s :
>>>
>>>> So, I tried to call the prelude's array_ptr_takeout() function, but 
>>>> that only works with a pointer of view array_v(), wereas I am using the 
>>>> arrayptr() viewtype.  To solve this, I called the cast function 
>>>> arrayptr_takeout_viewptr(), which seemed to suit my needs perfectly.  
>>>> Here's my code currently:
>>>
>>> implement model_print ( m ) = let
>>>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>>>   if i >= 0 then let
>>>>
>>> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar) // take out the 
>>>> view: the type of [ar] is changed!
>>>>
>>> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
>>>> size_of_int(i))
>>>>
>>> val () = mesh_print(!ar_i) 
>>> prval () = arrayptr_addback (pf_ar | ar) // put it back where it 
>>> belongs: [ar] is now the same type as it was on entry
>>>
>>>>   in
>>>>
>>> mesh_print_loop(i-1, ar)
>>>>   end else ()
>>>> in
>>>>   mesh_print_loop((m.0)-1, m.1)
>>>> end
>>>>
>>>
>>>> But, my code is producing the following errors:
>>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>>>> offs=26) -- 79402(line=2755, offs=28): error(3): the linear dynamic 
>>>> variable [ar$5912(-1)] is no longer available.
>>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>>>> offs=26) -- 79402(line=2755, offs=28): error(3): the dynamic expression 
>>>> cannot be assigned the type 
>>>> [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>>>> S2Ecst(mesh), S2EVar(7940), S2EVar(7942))].
>>>>
>>>> I assume the way to fix this would be to change "ar: !arrayptr(mesh, l, 
>>>> j)" to "ar: !arrayptr(mesh, l, j) >> ..." in the function inputs, but I'm 
>>>> unsure what exactly needs to go in the ".." part.  Any h

Re: How do I store a viewtype in an array and then access that value?

2020-09-27 Thread d4v3y_5c0n3s
Ice, thank you for your suggestion, once I get this working I should 
replace my handmade loops with arrayptr_foreach() calls like you suggested.
Artyom, I see what you were trying to do with your suggestion, but it 
didn't work due to the proof pf_ar being consumed by the 
array_ptr_takeout() call.

Here is the code for anyone who wants to see it:
implement model_print ( m ) = let
  fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
  ( i: int i, ar: !arrayptr(mesh, l, j)): void =
  if i >= 0 then let
val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar)
val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
size_of_int(i))
val () = mesh_print(!ar_i)
prval () = arrayptr_addback(pf_ar | ar_p)
  in
mesh_print_loop(i-1, ar)
  end else ()
in
  mesh_print_loop((m.0)-1, m.1)
end

Here is the error message from the compiler:
patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
offs=33) -- 79158(line=2750, offs=38): error(3): the linear dynamic 
variable [pf_ar$5913(-1)] is no longer available.
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79153(line=2750, 
offs=33) -- 79158(line=2750, offs=38): error(3): the dynamic expression 
cannot be assigned the type [S2Eat(S2Etyarr(S2Einvar(S2EVar(7937)); 
S2EVar(7939)), S2EVar(7938))].

I will continue to work on this, and I'll post if I come to a solution.
On Saturday, September 26, 2020 at 12:10:11 PM UTC-4 d4v3y_5c0n3s wrote:

> Awesome!  Thanks for all of these suggestions!  I'll try them later on and 
> then post how it went.
>
> On Saturday, September 26, 2020 at 10:56:07 AM UTC-4 artyom.s...@gmail.com 
> wrote:
>
>> Hi d4v3y,
>>
>> I will make a fix below that might work. However, as Alexander mentioned, 
>> if you only want to map an array (i.e. apply a function to each element), 
>> then you probably don't want to hand-roll a loop.
>>
>> сб, 26 сент. 2020 г. в 16:54, d4v3y_5c0n3s :
>>
>>> So, I tried to call the prelude's array_ptr_takeout() function, but that 
>>> only works with a pointer of view array_v(), wereas I am using the 
>>> arrayptr() viewtype.  To solve this, I called the cast function 
>>> arrayptr_takeout_viewptr(), which seemed to suit my needs perfectly.  
>>> Here's my code currently:
>>
>> implement model_print ( m ) = let
>>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>>   if i >= 0 then let
>>>
>> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar) // take out the 
>>> view: the type of [ar] is changed!
>>>
>> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
>>> size_of_int(i))
>>>
>> val () = mesh_print(!ar_i) 
>> prval () = arrayptr_addback (pf_ar | ar) // put it back where it 
>> belongs: [ar] is now the same type as it was on entry
>>
>>>   in
>>>
>> mesh_print_loop(i-1, ar)
>>>   end else ()
>>> in
>>>   mesh_print_loop((m.0)-1, m.1)
>>> end
>>>
>>
>>> But, my code is producing the following errors:
>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>>> offs=26) -- 79402(line=2755, offs=28): error(3): the linear dynamic 
>>> variable [ar$5912(-1)] is no longer available.
>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>>> offs=26) -- 79402(line=2755, offs=28): error(3): the dynamic expression 
>>> cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>>> S2Ecst(mesh), S2EVar(7940), S2EVar(7942))].
>>>
>>> I assume the way to fix this would be to change "ar: !arrayptr(mesh, l, 
>>> j)" to "ar: !arrayptr(mesh, l, j) >> ..." in the function inputs, but I'm 
>>> unsure what exactly needs to go in the ".." part.  Any help is appreciated, 
>>> and thanks for the previous suggestion.
>>> On Friday, September 25, 2020 at 8:43:10 AM UTC-4 d4v3y_5c0n3s wrote:
>>>
>>>> Thanks for the help!  Once I get the opportunity to test your 
>>>> suggestion of using array_ptr_takeout, I'll post whether it worked or not.
>>>>
>>>> On Friday, September 25, 2020 at 8:00:15 AM UTC-4 artyom.s...@gmail.com 
>>>> wrote:
>>>>
>>>>> пт, 25 сент. 2020 г. в 13:52, d4v3y_5c0n3s :
>>>>>
>>>>>> So, what I'm trying to do is create a type which res

Re: How do I store a viewtype in an array and then access that value?

2020-09-26 Thread d4v3y_5c0n3s
Awesome!  Thanks for all of these suggestions!  I'll try them later on and 
then post how it went.

On Saturday, September 26, 2020 at 10:56:07 AM UTC-4 artyom.s...@gmail.com 
wrote:

> Hi d4v3y,
>
> I will make a fix below that might work. However, as Alexander mentioned, 
> if you only want to map an array (i.e. apply a function to each element), 
> then you probably don't want to hand-roll a loop.
>
> сб, 26 сент. 2020 г. в 16:54, d4v3y_5c0n3s :
>
>> So, I tried to call the prelude's array_ptr_takeout() function, but that 
>> only works with a pointer of view array_v(), wereas I am using the 
>> arrayptr() viewtype.  To solve this, I called the cast function 
>> arrayptr_takeout_viewptr(), which seemed to suit my needs perfectly.  
>> Here's my code currently:
>
> implement model_print ( m ) = let
>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>   if i >= 0 then let
>>
> val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar) // take out the 
>> view: the type of [ar] is changed!
>>
> val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
>> size_of_int(i))
>>
> val () = mesh_print(!ar_i) 
> prval () = arrayptr_addback (pf_ar | ar) // put it back where it 
> belongs: [ar] is now the same type as it was on entry
>
>>   in
>>
> mesh_print_loop(i-1, ar)
>>   end else ()
>> in
>>   mesh_print_loop((m.0)-1, m.1)
>> end
>>
>
>> But, my code is producing the following errors:
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>> offs=26) -- 79402(line=2755, offs=28): error(3): the linear dynamic 
>> variable [ar$5912(-1)] is no longer available.
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
>> offs=26) -- 79402(line=2755, offs=28): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>> S2Ecst(mesh), S2EVar(7940), S2EVar(7942))].
>>
>> I assume the way to fix this would be to change "ar: !arrayptr(mesh, l, 
>> j)" to "ar: !arrayptr(mesh, l, j) >> ..." in the function inputs, but I'm 
>> unsure what exactly needs to go in the ".." part.  Any help is appreciated, 
>> and thanks for the previous suggestion.
>> On Friday, September 25, 2020 at 8:43:10 AM UTC-4 d4v3y_5c0n3s wrote:
>>
>>> Thanks for the help!  Once I get the opportunity to test your suggestion 
>>> of using array_ptr_takeout, I'll post whether it worked or not.
>>>
>>> On Friday, September 25, 2020 at 8:00:15 AM UTC-4 artyom.s...@gmail.com 
>>> wrote:
>>>
>>>> пт, 25 сент. 2020 г. в 13:52, d4v3y_5c0n3s :
>>>>
>>>>> So, what I'm trying to do is create a type which resembles the 
>>>>> following:
>>>>>
>>>>> absvt@ype model = [l:addr][n:nat] ( int n, arrayptr(mesh, l, n) )
>>>>>
>>>>> Where "mesh" is also an absvt@ype.  ATS lets me create this type fine, 
>>>>> but I run into an issue when I try to index the array in the following 
>>>>> code:
>>>>>
>>>>> implement model_print ( m ) = let
>>>>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>>>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>>>>   if i >= 0 then let
>>>>>   in
>>>>> mesh_print(ar[i]);
>>>>> mesh_print_loop(i-1, ar)
>>>>>   end else ()
>>>>> in
>>>>>   mesh_print_loop((m.0)-1, m.1)
>>>>> end
>>>>>
>>>>> I get the following error messages:
>>>>>
>>>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>>>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>>>>> offs=16) -- 79211(line=2749, offs=19): error(3): the dynamic expression 
>>>>> cannot be assigned the type 
>>>>> [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>>>>> S2Einvar(S2EVar(7929)), S2EVar(7933), S2EVar(7931))].
>>>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>>>>> offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of sorts in 
>>>>> unification:
>>>>> The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
>>>

Re: How do I store a viewtype in an array and then access that value?

2020-09-26 Thread d4v3y_5c0n3s
So, I tried to call the prelude's array_ptr_takeout() function, but that 
only works with a pointer of view array_v(), wereas I am using the 
arrayptr() viewtype.  To solve this, I called the cast function 
arrayptr_takeout_viewptr(), which seemed to suit my needs perfectly.  
Here's my code currently:
implement model_print ( m ) = let
  fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
  ( i: int i, ar: !arrayptr(mesh, l, j)): void =
  if i >= 0 then let
//may need to use the ">>" syntax in order to do the below cast
//step 1: cast arrayptr to array_v & ptr using 
arrayptr_takeout_viewptr()
var ar_copy = ar
val (pf_ar | ar_p) = arrayptr_takeout_viewptr(ar_copy)
//step 2: call array_ptr_takeout() to get the viewtype for the given 
element
val (ar_ipf1, ar_ipf2 | ar_i) = array_ptr_takeout(pf_ar | ar_p, 
size_of_int(i))
  in
mesh_print(!ar_i);
mesh_print_loop(i-1, ar)
  end else ()
in
  mesh_print_loop((m.0)-1, m.1)
end

But, my code is producing the following errors:
patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
offs=26) -- 79402(line=2755, offs=28): error(3): the linear dynamic 
variable [ar$5912(-1)] is no longer available.
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79400(line=2755, 
offs=26) -- 79402(line=2755, offs=28): error(3): the dynamic expression 
cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
S2Ecst(mesh), S2EVar(7940), S2EVar(7942))].

I assume the way to fix this would be to change "ar: !arrayptr(mesh, l, j)" 
to "ar: !arrayptr(mesh, l, j) >> ..." in the function inputs, but I'm 
unsure what exactly needs to go in the ".." part.  Any help is appreciated, 
and thanks for the previous suggestion.
On Friday, September 25, 2020 at 8:43:10 AM UTC-4 d4v3y_5c0n3s wrote:

> Thanks for the help!  Once I get the opportunity to test your suggestion 
> of using array_ptr_takeout, I'll post whether it worked or not.
>
> On Friday, September 25, 2020 at 8:00:15 AM UTC-4 artyom.s...@gmail.com 
> wrote:
>
>> пт, 25 сент. 2020 г. в 13:52, d4v3y_5c0n3s :
>>
>>> So, what I'm trying to do is create a type which resembles the following:
>>>
>>> absvt@ype model = [l:addr][n:nat] ( int n, arrayptr(mesh, l, n) )
>>>
>>> Where "mesh" is also an absvt@ype.  ATS lets me create this type fine, 
>>> but I run into an issue when I try to index the array in the following code:
>>>
>>> implement model_print ( m ) = let
>>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>>   if i >= 0 then let
>>>   in
>>> mesh_print(ar[i]);
>>> mesh_print_loop(i-1, ar)
>>>   end else ()
>>> in
>>>   mesh_print_loop((m.0)-1, m.1)
>>> end
>>>
>>> I get the following error messages:
>>>
>>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>>> offs=16) -- 79211(line=2749, offs=19): error(3): the dynamic expression 
>>> cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>>> S2Einvar(S2EVar(7929)), S2EVar(7933), S2EVar(7931))].
>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>>> offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of sorts in 
>>> unification:
>>> The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
>>> The sort of solution is: S2RTbas(S2RTBASimp(3; viewt0ype))
>>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>>> offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of static terms 
>>> (tyleq):
>>> The actual term is: S2Ecst(mesh)
>>> The needed term is: S2Einvar(S2EVar(7929->S2Ecst(mesh)))
>>>
>>> I've looked at the prelude, and the issue appears to be that all of the 
>>> functions for indexing an array use "t0p" instead of "vt0p," which is what 
>>> I need.  What I'd like to know is, is there cleaner way to do what I'm 
>>> trying to accomplish?  I figure I could write my own function that 
>>> overrides [], but is there another way?
>>>
>>
>> A subscription like a[i] involves copying the element at position i in 
>> the array. If this element is itself linear (i.e. vt0p), we can't easily 
>> duplicate it (copy it).
>>
>> You will have to use array_ptr_takeout instead. It will give you a 
>> pointer to the i'

Re: How do I store a viewtype in an array and then access that value?

2020-09-25 Thread d4v3y_5c0n3s
Thanks for the help!  Once I get the opportunity to test your suggestion of 
using array_ptr_takeout, I'll post whether it worked or not.

On Friday, September 25, 2020 at 8:00:15 AM UTC-4 artyom.s...@gmail.com 
wrote:

> пт, 25 сент. 2020 г. в 13:52, d4v3y_5c0n3s :
>
>> So, what I'm trying to do is create a type which resembles the following:
>>
>> absvt@ype model = [l:addr][n:nat] ( int n, arrayptr(mesh, l, n) )
>>
>> Where "mesh" is also an absvt@ype.  ATS lets me create this type fine, 
>> but I run into an issue when I try to index the array in the following code:
>>
>> implement model_print ( m ) = let
>>   fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
>>   ( i: int i, ar: !arrayptr(mesh, l, j)): void =
>>   if i >= 0 then let
>>   in
>> mesh_print(ar[i]);
>> mesh_print_loop(i-1, ar)
>>   end else ()
>> in
>>   mesh_print_loop((m.0)-1, m.1)
>> end
>>
>> I get the following error messages:
>>
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>> offs=16) -- 79211(line=2749, offs=19): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
>> S2Einvar(S2EVar(7929)), S2EVar(7933), S2EVar(7931))].
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>> offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of sorts in 
>> unification:
>> The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
>> The sort of solution is: S2RTbas(S2RTBASimp(3; viewt0ype))
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
>> offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of static terms 
>> (tyleq):
>> The actual term is: S2Ecst(mesh)
>> The needed term is: S2Einvar(S2EVar(7929->S2Ecst(mesh)))
>>
>> I've looked at the prelude, and the issue appears to be that all of the 
>> functions for indexing an array use "t0p" instead of "vt0p," which is what 
>> I need.  What I'd like to know is, is there cleaner way to do what I'm 
>> trying to accomplish?  I figure I could write my own function that 
>> overrides [], but is there another way?
>>
>
> A subscription like a[i] involves copying the element at position i in the 
> array. If this element is itself linear (i.e. vt0p), we can't easily 
> duplicate it (copy it).
>
> You will have to use array_ptr_takeout instead. It will give you a pointer 
> to the i'th element of the array and a proof function for "trading" the 
> associated at-view for the full array view.
>  
>
>>
>> Thank you to anyone who can help me out with this problem.  Have an 
>> awesome day.
>>
>
> Thanks! You too, have a great day.
>  
>
>> -- 
>> 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/084b0cda-c769-4078-a20b-ab10345958a9n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/084b0cda-c769-4078-a20b-ab10345958a9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Cheers,
> Artyom Shalkhakov
>

-- 
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/bf350322-4188-4c33-961f-d2242c20bb45n%40googlegroups.com.


How do I store a viewtype in an array and then access that value?

2020-09-25 Thread d4v3y_5c0n3s
So, what I'm trying to do is create a type which resembles the following:

absvt@ype model = [l:addr][n:nat] ( int n, arrayptr(mesh, l, n) )

Where "mesh" is also an absvt@ype.  ATS lets me create this type fine, but 
I run into an issue when I try to index the array in the following code:

implement model_print ( m ) = let
  fun mesh_print_loop {l:addr}{i,j:int | 0 <= i+1; i+1 <= j} ..
  ( i: int i, ar: !arrayptr(mesh, l, j)): void =
  if i >= 0 then let
  in
mesh_print(ar[i]);
mesh_print_loop(i-1, ar)
  end else ()
in
  mesh_print_loop((m.0)-1, m.1)
end

I get the following error messages:

patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
offs=16) -- 79211(line=2749, offs=19): error(3): the dynamic expression 
cannot be assigned the type [S2Eapp(S2Ecst(arrayptr_vt0ype_addr_int_vtype); 
S2Einvar(S2EVar(7929)), S2EVar(7933), S2EVar(7931))].
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of sorts in 
unification:
The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
The sort of solution is: S2RTbas(S2RTBASimp(3; viewt0ype))
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 79208(line=2749, 
offs=16) -- 79211(line=2749, offs=19): error(3): mismatch of static terms 
(tyleq):
The actual term is: S2Ecst(mesh)
The needed term is: S2Einvar(S2EVar(7929->S2Ecst(mesh)))

I've looked at the prelude, and the issue appears to be that all of the 
functions for indexing an array use "t0p" instead of "vt0p," which is what 
I need.  What I'd like to know is, is there cleaner way to do what I'm 
trying to accomplish?  I figure I could write my own function that 
overrides [], but is there another way?

Thank you to anyone who can help me out with this problem.  Have an awesome 
day.

-- 
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/084b0cda-c769-4078-a20b-ab10345958a9n%40googlegroups.com.


Re: unsolved constraint for termetric being well-founded

2020-09-03 Thread d4v3y_5c0n3s
This worked!  Thank you. :D

On Thursday, September 3, 2020 at 4:27:00 PM UTC-4 gmhwxi wrote:

> A termination metric is required to be non-negative. Try to change .. 
> into ..
>
> On Thu, Sep 3, 2020 at 2:57 PM d4v3y_5c0n3s  wrote:
>
>> So, I've been encountering this "unsolved constraint for termetric being 
>> well-founded" error message, and I'm not sure how to fix it.  Does this 
>> mean that I'm not being strict enough with types?
>>
>> Here's my code:
>>
>> absvt@ype mesh
>>
>> assume mesh =
>> [v,t:nat]
>> [vl,tl:addr]
>> @{
>>   v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, 
>> t)
>> }
>>
>> implement mesh_print ( m ) = let
>>   fun vert_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
>> v_arr: &(arrayptr(vertex, j)) ): void =
>> if not(i < 0) then begin
>>   vertex_print(v_arr[i]);
>>   vert_print_loop(i-1, v_arr)
>> end else ()
>>   fun tri_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
>> t_arr: &(arrayptr(uint32, j)) ): void =
>> if not(i < 0) then begin
>>   println!(t_arr[i]);
>>   tri_print_loop(i-1, t_arr)
>> end else ()
>> in
>>   println!("Num Verts: ", m.v);
>>   vert_print_loop(m.v-1, m.vap);
>>   println!("Num Tris: ", m.t);
>>   println!("Triangle Indicies");
>>   tri_print_loop(m.t-1, m.tap)
>> end
>>
>> Here's the errors:
>>
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 67738(line=2381, 
>> offs=54) -- 67904(line=2385, offs=16): error(3): unsolved constraint for 
>> termetric being well-founded: C3NSTRprop(C3TKtermet_isnat(); 
>> S2Eapp(S2Ecst(gte_int_int); S2Evar(i(8786)), S2Eint(0)))
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 67957(line=2386, 
>> offs=53) -- 68118(line=2390, offs=16): error(3): unsolved constraint for 
>> termetric being well-founded
>> typechecking has failed: there are some unsolved constraints: please 
>> inspect the above reported error message(s) for information.
>> exit(ATS): uncaught exception: 
>> _2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
>>
>> Please ask if you need any additional information.
>>
>> -- 
>> 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/442cef10-e62a-4873-96d9-00cec346390dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/442cef10-e62a-4873-96d9-00cec346390dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/3c4423ca-d843-49d9-9401-ae80cbe89b80n%40googlegroups.com.


Re: unsolved constraint for termetric being well-founded

2020-09-03 Thread d4v3y_5c0n3s
Okay, thanks.  I'll try to rework the loop then.  Thank you, you've been a 
big help. :)

On Thursday, September 3, 2020 at 3:24:59 PM UTC-4 ice.r...@gmail.com wrote:

> that i >= 0 *
>
> чт, 3 сент. 2020 г. в 19:24, Dambaev Alexander :
>
>> hi
>> as far as I can see, the error message asks to prove, that i > 0. You 
>> have constraint i+1 >= 0, so i can be ~1, which is not natural number, but 
>> quite from tutorial:
>> ```
>> A termination metric is just a tuple of *natural* numbers and the 
>> standard lexicographic ordering on *natural* numbers is used to order 
>> such tuples.
>> ```
>> and that is why you see ```C3TKtermet_isnat()```
>>
>

-- 
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/5837819a-c930-4661-a45b-fadd6f173213n%40googlegroups.com.


unsolved constraint for termetric being well-founded

2020-09-03 Thread d4v3y_5c0n3s
So, I've been encountering this "unsolved constraint for termetric being 
well-founded" error message, and I'm not sure how to fix it.  Does this 
mean that I'm not being strict enough with types?

Here's my code:

absvt@ype mesh

assume mesh =
[v,t:nat]
[vl,tl:addr]
@{
  v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, t)
}

implement mesh_print ( m ) = let
  fun vert_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
v_arr: &(arrayptr(vertex, j)) ): void =
if not(i < 0) then begin
  vertex_print(v_arr[i]);
  vert_print_loop(i-1, v_arr)
end else ()
  fun tri_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
t_arr: &(arrayptr(uint32, j)) ): void =
if not(i < 0) then begin
  println!(t_arr[i]);
  tri_print_loop(i-1, t_arr)
end else ()
in
  println!("Num Verts: ", m.v);
  vert_print_loop(m.v-1, m.vap);
  println!("Num Tris: ", m.t);
  println!("Triangle Indicies");
  tri_print_loop(m.t-1, m.tap)
end

Here's the errors:

patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 67738(line=2381, 
offs=54) -- 67904(line=2385, offs=16): error(3): unsolved constraint for 
termetric being well-founded: C3NSTRprop(C3TKtermet_isnat(); 
S2Eapp(S2Ecst(gte_int_int); S2Evar(i(8786)), S2Eint(0)))
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 67957(line=2386, 
offs=53) -- 68118(line=2390, offs=16): error(3): unsolved constraint for 
termetric being well-founded
typechecking has failed: there are some unsolved constraints: please 
inspect the above reported error message(s) for information.
exit(ATS): uncaught exception: 
_2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)

Please ask if you need any additional information.

-- 
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/442cef10-e62a-4873-96d9-00cec346390dn%40googlegroups.com.


Re: How to Free a Pointer to a viewt@ype

2020-09-03 Thread d4v3y_5c0n3s
Thanks for the help, this worked. :)

On Wednesday, September 2, 2020 at 11:50:13 PM UTC-4 gmhwxi wrote:

> The type-checker has quite a few limitations in handling existential 
> quantifiers.
> Here is a way to circumvent the problem:
>
>   implement
>   mesh_delete( mpf, mpff | m ) =
>   let
> val m1 = !m
>   in
> arrayptr_free(m1.vap);
> arrayptr_free(m1.tap);
> ptr_free(mpff, mpf | m)
>   end
>
>
>   implement
>   mesh_delete( mpf, mpff | m ) =
>   let
> val m1 = !m
>   in
> arrayptr_free(m1.vap);
> arrayptr_free(m1.tap);
> ptr_free(mpff, mpf | m)
>   end
>
>
>
> On Wed, Sep 2, 2020 at 11:04 PM d4v3y_5c0n3s  wrote:
>
>> So, I've got the following code:
>> absvt@ype mesh
>>
>> assume mesh =
>> [v,t:int]
>> [vl,tl:addr]
>> @{
>>   v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, 
>> t)
>> }
>>
>> fun mesh_delete {l:addr} ( mpf: mesh @ l, mpff: mfree_gc_v(l) | m: ptr l 
>> ) : void = "sta#%"
>>
>> implement mesh_delete ( mpf, mpff | m ) =
>> (
>>   arrayptr_free(!m.vap);
>>   arrayptr_free(!m.tap);
>>   ptr_free(mpff, mpf | m)
>> )
>>
>> However, I'm getting the following error:
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
>> offs=18) -- 69185(line=2426, offs=21): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eat(S2EVar(7167), S2Evar(l$3392(8793)))].
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
>> offs=18) -- 69185(line=2426, offs=21): error(3): mismatch of sorts in 
>> unification:
>> The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
>> The sort of solution is: S2RTbas(S2RTBASimp(3; viewt0ype))
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
>> offs=18) -- 69185(line=2426, offs=21): error(3): mismatch of static terms 
>> (tyleq):
>> The actual term is: S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); 
>> S2Evar(v$10840(16813))), t=S2Eapp(S2Ecst(int); S2Evar(t$10841(16814))), 
>> vap=S2Ecst(ptr_type), tap=S2Ecst(ptr_type))
>> The needed term is: S2EVar(7167)
>>
>> I can allocate a pointer to mesh using ptr_alloc just fine, so why is 
>> ptr_free not working?  Do I need to get rid of the view to deallocate, 
>> perhaps using unsafe casting/functions?  Any help is appreciated, and if 
>> you'd like to see more of the code then please, ask me,
>>
>> -- 
>> 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/3a5cd9b9-2ef3-4d32-8513-a4e952c09d26n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/3a5cd9b9-2ef3-4d32-8513-a4e952c09d26n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/279f0e1c-1872-4e29-bcf0-df9404eb952bn%40googlegroups.com.


How to Free a Pointer to a viewt@ype

2020-09-02 Thread d4v3y_5c0n3s
So, I've got the following code:
absvt@ype mesh

assume mesh =
[v,t:int]
[vl,tl:addr]
@{
  v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, t)
}

fun mesh_delete {l:addr} ( mpf: mesh @ l, mpff: mfree_gc_v(l) | m: ptr l ) 
: void = "sta#%"

implement mesh_delete ( mpf, mpff | m ) =
(
  arrayptr_free(!m.vap);
  arrayptr_free(!m.tap);
  ptr_free(mpff, mpf | m)
)

However, I'm getting the following error:
patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
offs=18) -- 69185(line=2426, offs=21): error(3): the dynamic expression 
cannot be assigned the type [S2Eat(S2EVar(7167), S2Evar(l$3392(8793)))].
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
offs=18) -- 69185(line=2426, offs=21): error(3): mismatch of sorts in 
unification:
The sort of variable is: S2RTbas(S2RTBASimp(1; t@ype))
The sort of solution is: S2RTbas(S2RTBASimp(3; viewt0ype))
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 69182(line=2426, 
offs=18) -- 69185(line=2426, offs=21): error(3): mismatch of static terms 
(tyleq):
The actual term is: S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); 
S2Evar(v$10840(16813))), t=S2Eapp(S2Ecst(int); S2Evar(t$10841(16814))), 
vap=S2Ecst(ptr_type), tap=S2Ecst(ptr_type))
The needed term is: S2EVar(7167)

I can allocate a pointer to mesh using ptr_alloc just fine, so why is 
ptr_free not working?  Do I need to get rid of the view to deallocate, 
perhaps using unsafe casting/functions?  Any help is appreciated, and if 
you'd like to see more of the code then please, ask me,

-- 
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/3a5cd9b9-2ef3-4d32-8513-a4e952c09d26n%40googlegroups.com.


Re: Initializing An Array Within a Record Allocated Within a Pointer

2020-09-01 Thread d4v3y_5c0n3s
It was really that simple?  Well, your solution worked.  Thanks, I was 
completely dumbfounded there.

On Tuesday, September 1, 2020 at 6:05:54 PM UTC-4 gmhwxi wrote:

> Please try:
>
> !res_ptr := (@{...} : mesh);
>
>
> On Tue, Sep 1, 2020 at 4:57 PM d4v3y_5c0n3s  wrote:
>
>> Good evening,
>> So, here's a snippet of code where I'm trying to create a record type 
>> that gets allocated within a pointer.  Also, I am trying to allocate arrays 
>> within this record type.  I've been stuck on this for too long, so I was 
>> looking for an outsider's perspective on how I might solve this.
>> Here's the code (error is highlighted in yellow):
>> absvt@ype mesh
>>
>> local
>>
>> assume mesh =
>> [v,t:int]
>> [vl,tl:addr]
>> @{
>>   v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, 
>> t)
>> }
>>
>> in
>>
>> implement mesh_print ( m ) = let
>>   fun vert_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
>> v_arr: &(arrayptr(vertex, j)) ): void =
>> if not(i < 0) then begin
>>   vertex_print(v_arr[i]);
>>   vert_print_loop(i-1, v_arr)
>> end else ()
>>   fun tri_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
>> t_arr: &(arrayptr(uint32, j)) ): void =
>> if not(i < 0) then begin
>>   println!(t_arr[i]);
>>   tri_print_loop(i-1, t_arr)
>> end else ()
>> in
>>   println!("Num Verts: ", m.v);
>>   vert_print_loop(m.v-1, m.vap);
>>   println!("Num Tris: ", m.t);
>>   println!("Triangle Indicies");
>>   tri_print_loop(m.t-1, m.tap)
>> end
>>
>> implement mesh_new (  ) = let
>>   val vert_array = arrayptr_make_uninitized(size_of_int(0))
>>   val tri_array = arrayptr_make_uninitized(size_of_int(0))
>>   val (res_mpf, res_gcpf | res_ptr) = ptr_alloc()
>> in
>>   arrayptr_initize(vert_array, size_of_int(0));
>>   arrayptr_initize(tri_array, size_of_int(0));
>>   !res_ptr := @{
>> v=0, t=0,
>> vap=vert_array,
>> tap=tri_array
>>   }:mesh;
>>   (res_mpf, res_gcpf | res_ptr)
>> end
>>
>> end
>> Here's the error message:
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, 
>> offs=3) -- 69025(line=2418, offs=4): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eexi(v(8781), t(8782); ; S2Eexi(vl(8783), 
>> tl(8784); ; S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); S2Evar(v(8781))), 
>> t=S2Eapp(S2Ecst(int); S2Evar(t(8782))), vap=S2Eapp(S2Ecst(arrayptr); 
>> S2Ecst(vertex), S2Evar(vl(8783)), S2Evar(v(8781))), 
>> tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2Evar(tl(8784)), 
>> S2Evar(t(8782))].
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, 
>> offs=3) -- 69025(line=2418, offs=4): error(3): mismatch of static terms 
>> (tyleq):
>> The actual term is: S2Ecst(atsvoid_t0ype)
>> The needed term is: S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); 
>> S2EVar(7152)), t=S2Eapp(S2Ecst(int); S2EVar(7153)), 
>> vap=S2Eapp(S2Ecst(arrayptr); S2Ecst(vertex), S2EVar(7154), S2EVar(7152)), 
>> tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2EVar(7155), S2EVar(7153)))
>> Thanks for any help, and let me know if you need more details from 
>> the code.
>> Have a great day,
>> Troy Jacobs
>>
>> -- 
>> 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/8fc97318-1f07-4261-a747-70f7edf00747n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/8fc97318-1f07-4261-a747-70f7edf00747n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/c495df7f-c9da-43c2-bb2d-97d15ab41fe3n%40googlegroups.com.


Initializing An Array Within a Record Allocated Within a Pointer

2020-09-01 Thread d4v3y_5c0n3s
Good evening,
So, here's a snippet of code where I'm trying to create a record type 
that gets allocated within a pointer.  Also, I am trying to allocate arrays 
within this record type.  I've been stuck on this for too long, so I was 
looking for an outsider's perspective on how I might solve this.
Here's the code (error is highlighted in yellow):
absvt@ype mesh

local

assume mesh =
[v,t:int]
[vl,tl:addr]
@{
  v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, t)
}

in

implement mesh_print ( m ) = let
  fun vert_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
v_arr: &(arrayptr(vertex, j)) ): void =
if not(i < 0) then begin
  vertex_print(v_arr[i]);
  vert_print_loop(i-1, v_arr)
end else ()
  fun tri_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .. ( i: int i, 
t_arr: &(arrayptr(uint32, j)) ): void =
if not(i < 0) then begin
  println!(t_arr[i]);
  tri_print_loop(i-1, t_arr)
end else ()
in
  println!("Num Verts: ", m.v);
  vert_print_loop(m.v-1, m.vap);
  println!("Num Tris: ", m.t);
  println!("Triangle Indicies");
  tri_print_loop(m.t-1, m.tap)
end

implement mesh_new (  ) = let
  val vert_array = arrayptr_make_uninitized(size_of_int(0))
  val tri_array = arrayptr_make_uninitized(size_of_int(0))
  val (res_mpf, res_gcpf | res_ptr) = ptr_alloc()
in
  arrayptr_initize(vert_array, size_of_int(0));
  arrayptr_initize(tri_array, size_of_int(0));
  !res_ptr := @{
v=0, t=0,
vap=vert_array,
tap=tri_array
  }:mesh;
  (res_mpf, res_gcpf | res_ptr)
end

end
Here's the error message:
patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, offs=3) 
-- 69025(line=2418, offs=4): error(3): the dynamic expression cannot be 
assigned the type [S2Eexi(v(8781), t(8782); ; S2Eexi(vl(8783), tl(8784); ; 
S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); S2Evar(v(8781))), 
t=S2Eapp(S2Ecst(int); S2Evar(t(8782))), vap=S2Eapp(S2Ecst(arrayptr); 
S2Ecst(vertex), S2Evar(vl(8783)), S2Evar(v(8781))), 
tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2Evar(tl(8784)), 
S2Evar(t(8782))].
/home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, offs=3) 
-- 69025(line=2418, offs=4): error(3): mismatch of static terms (tyleq):
The actual term is: S2Ecst(atsvoid_t0ype)
The needed term is: S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); 
S2EVar(7152)), t=S2Eapp(S2Ecst(int); S2EVar(7153)), 
vap=S2Eapp(S2Ecst(arrayptr); S2Ecst(vertex), S2EVar(7154), S2EVar(7152)), 
tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2EVar(7155), S2EVar(7153)))
Thanks for any help, and let me know if you need more details from the 
code.
Have a great day,
Troy Jacobs

-- 
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/8fc97318-1f07-4261-a747-70f7edf00747n%40googlegroups.com.


Re: ATS Github repos Twitter bot

2020-08-20 Thread d4v3y_5c0n3s
That's pretty cool!  I'm not really the Twitter type, but I like the idea 
of this project. :D

On Wednesday, August 19, 2020 at 12:07:02 PM UTC-4 Timmy Jose wrote:

>
> Hello,
>
> I have created a new Twitter bot that queries Github for newly-created ATS 
> lang repos and tweets a brief summary about them. 
> https://twitter.com/NewATSRepos. 
>
> Feel free to check it out! :-)
>
> Cheers,
>
> Timmy
>

-- 
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/d7eed881-fa32-4e6c-842c-9d09a9a6ad2dn%40googlegroups.com.


Re: Issue with conditionally mutating a var twice

2020-07-18 Thread d4v3y_5c0n3s
Thanks everyone, you were all extremely helpful!  I appreciate the advice 
too, and I'll look into using your suggestions to improve the code. Again, 
thanks! :D

On Thursday, July 16, 2020 at 8:12:39 AM UTC-4, d4v3y_5c0n3s wrote:
>
>   So, I'm trying to mutate a var twice in order to replicate some C code 
> that I am trying to port to ATS.  But, I've been scratching my head as to 
> why this would happen, so any help is appreciated.  In an effort to not 
> waste your time, I will be showing you the function with my issue along 
> with the declarations for the relevant functions & typedefs.  Please ask if 
> you'd like me to provide more details that I may have missed.
>
> The function I'm having trouble in:
>
> implement mat4_to_quat ( m ) = let
>   val tr = m.xx + m.yy + m.zz
> in
>   if tr > 0.f then let
> val s = $MATH.sqrt(tr + 1.f)
> val w = s / 2.f
> val x = ( mat4_at(m, 1, 2) - mat4_at(m, 2, 1) ) * (0.5f / s)
> val y = ( mat4_at(m, 2, 0) - mat4_at(m, 0, 2) ) * (0.5f / s)
> val z = ( mat4_at(m, 0, 1) - mat4_at(m, 1, 0) ) * (0.5f / s)
>   in
> quat_new(x, y, z, w)
>   end else let
> val nxt = @[int](1, 2, 0)
> var q = @[float][4](0.f)
> var i = 0
> var j = 0
> var k = 0
> var s = 0
>   in
> *i := ((if mat4_at(m, 1, 1) > mat4_at(m, 0, 0) then 1 else i):int);*
> *i := ((if mat4_at(m, 2, 2) > mat4_at(m, $showtype(i), i) then 2 else 
> i):int);  // <-- this line has the error*
> j := nxt[i];
> k := nxt[j];
> s := $MATH.sqrt( (mat4_at(m, i, i) - (mat4_at(m, j, j), mat4_at(m, k, 
> k))) + 1.f );
> q[i] := s * 0.5f;
> s := (if (s != 0.f) then 0.5f / s else s);
> q[3] := (mat4_at(m, j, k) - mat4_at(m, k, j)) * s;
> q[j] := (mat4_at(m, i, j) + mat4_at(m, j, i)) * s;
> q[k] := (mat4_at(m, i, k) + mat4_at(m, k, i)) * s;
> quat_new(q[0], q[1], q[2], q[3])
>   end
> end
>
>
> Here's the function's declaration:
>
> fun mat4_to_quat ( m: mat4 ) : quat = "sta#%"
>
>
> Here's the declaration for mat4_at:
>
> fun mat4_at {x:nat | x < 4}{y:nat | y < 4} ( m: mat4, x: int x, y: int y ) 
> : float = "sta#%"
>
>
> My full repo can be found here: 
> https://github.com/d4v3y5c0n3s/Goldelish-Engine
> Here's the error message:
>
> patscc -tcats /home/d4v3y/Goldelish-Engine/source/g_engine.dats
> **SHOWTYPE[UP]**(/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 
> 35508(line=1373, offs=55) -- 35509(line=1373, offs=56)): 
> S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int)): S2RTbas(S2RTBASimp(1; 
> t@ype))
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
> offs=55) -- 35509(line=1373, offs=56): error(3): the dynamic expression 
> cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6368))].
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
> offs=55) -- 35509(line=1373, offs=56): error(3): mismatch of static terms 
> (tyleq):
> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6368))
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
> offs=59) -- 35513(line=1373, offs=60): error(3): the dynamic expression 
> cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6369))].
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
> offs=59) -- 35513(line=1373, offs=60): error(3): mismatch of static terms 
> (tyleq):
> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6369))
>
> |
>

-- 
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/0b3447c4-47cc-47f9-8649-19f55ec5d22do%40googlegroups.com.


Re: Issue with conditionally mutating a var twice

2020-07-17 Thread d4v3y_5c0n3s
Okay, so gmhwxi's suggestion to use natLt(2) & natLt(3) seems to have 
worked, but I'm having trouble understanding what natLt(2) & natLt(3) 
actually is.  

*Could anyone explain what natLt(2) & natLt(3) mean, please?*  After 
looking at the prelude the definition of natLt() doesn't seem 
self-explanatory.

As for the suggestions to use separate val-declarations in a more 
functional style, my reason for taking this approach is that I am trying to 
replicate some C code in ATS.  *I do agree that this is probably not the 
cleanest solution, I figure that I can revise it later once I get my 
overall project working.*  But I appreciate the suggestions, so thank you.

Going off of what Dambaev said, *it makes sense to prove to the compiler 
that 'i' is >= 0 && < 4, but what sort of statements might I use for this? * 
I worked through chapter 12 of Intro to Programming in ATS, but I'm still 
quite unsure on how to use proofs effectively.  Thanks for this advice, 
Dambaev.

Lastly, *I am running into an issue with indexing an array where the 
compiler says that the function argument must be a left-value.*  I assume 
that 'nxt' is the one that needs to be a left-value, but !nxt doesn't make 
a difference.  Any help that can be provided is appreciated.

Apologies for the long response, I wanted to make sure I responded to as 
many of you as possible, because you've all been really helpful. :)

Here's my updated function:

implement mat4_to_quat ( m ) = let
  val tr = m.xx + m.yy + m.zz
in
  if tr > 0.f then let
val s = $MATH.sqrt(tr + 1.f)
val w = s / 2.f
val x = ( mat4_at(m, 1, 2) - mat4_at(m, 2, 1) ) * (0.5f / s)
val y = ( mat4_at(m, 2, 0) - mat4_at(m, 0, 2) ) * (0.5f / s)
val z = ( mat4_at(m, 0, 1) - mat4_at(m, 1, 0) ) * (0.5f / s)
  in
quat_new(x, y, z, w)
  end else let
val nxt = @[int](1, 2, 0)
var q = @[float][4](0.f)
var i = 0
var j = 0
var k = 0
var s = 0
  in
i := ((if mat4_at(m, 1, 1) > mat4_at(m, 0, 0) then 1 else i):natLt(2));
i := ((if mat4_at(m, 2, 2) > mat4_at(m, i, i) then 2 else i):natLt(3));
*j := nxt[i];  <-- first error message is on this line*
k := nxt[j];
s := $MATH.sqrt( (mat4_at(m, i, i) - (mat4_at(m, j, j), mat4_at(m, k, 
k))) + 1.f );
q[i] := s * 0.5f;
s := (if (s != 0.f) then 0.5f / s else s);
q[3] := (mat4_at(m, j, k) - mat4_at(m, k, j)) * s;
q[j] := (mat4_at(m, i, j) + mat4_at(m, j, i)) * s;
q[k] := (mat4_at(m, i, k) + mat4_at(m, k, i)) * s;
quat_new(q[0], q[1], q[2], q[3])
  end
end


Here's the new error message:

patscc -tcats /home/d4v3y/Goldelish-Engine/source/g_engine.dats
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35545(line=1374, 
offs=11) -- 35549(line=1374, offs=15): error(3): the function argument 
needs to be a left-value.
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35544(line=1374, 
offs=10) -- 35551(line=1374, offs=17): error(3): the symbol [!] cannot be 
resolved as no match is found.
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35539(line=1374, offs=5) 
-- 35551(line=1374, offs=17): error(3): assignment cannot be performed: 
mismatch of bef/aft type-sizes:
bef: [S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), 
S2Eintinf(0))]
aft: [S2Eerrexp()]
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35562(line=1375, 
offs=10) -- 35568(line=1375, offs=16): error(3): the symbol [[]] cannot be 
resolved due to too many matches:
D2ITMcst(array_get_at_guint) of 0
D2ITMcst(array_get_at_gint) of 0
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35557(line=1375, offs=5) 
-- 35568(line=1375, offs=16): error(3): assignment cannot be performed: 
mismatch of bef/aft type-sizes:
bef: [S2Eapp(S2Ecst(g1int_int_t0ype); S2Eextkind(atstype_int), 
S2Eintinf(0))]
aft: [S2Eerrexp()]


On Thursday, July 16, 2020 at 8:12:39 AM UTC-4, d4v3y_5c0n3s wrote:
>
>   So, I'm trying to mutate a var twice in order to replicate some C code 
> that I am trying to port to ATS.  But, I've been scratching my head as to 
> why this would happen, so any help is appreciated.  In an effort to not 
> waste your time, I will be showing you the function with my issue along 
> with the declarations for the relevant functions & typedefs.  Please ask if 
> you'd like me to provide more details that I may have missed.
>
> The function I'm having trouble in:
>
> implement mat4_to_quat ( m ) = let
>   val tr = m.xx + m.yy + m.zz
> in
>   if tr > 0.f then let
> val s = $MATH.sqrt(tr + 1.f)
> val w = s / 2.f
> val x = ( mat4_at(m, 1, 2) - mat4_at(m, 2, 1) ) * (0.5f / s)
> val y = ( mat4_at(m, 2, 0) - mat4_at(m, 0, 2) ) * (0.5f / s)
> val z = ( mat4_at(m, 0, 1) - mat4_at(m, 1, 0) ) * (0.5f / s)
>   in
> quat_new(x, y, z, w)
>   end else let
> val nxt = @[int](1, 2, 0)
> var q 

Re: Issue with conditionally mutating a var twice

2020-07-16 Thread d4v3y_5c0n3s
Thanks everyone, I will be trying all of your suggestions and let you know 
whether they resolve my issue. :D

On Thursday, July 16, 2020 at 8:12:39 AM UTC-4, d4v3y_5c0n3s wrote:
>
>   So, I'm trying to mutate a var twice in order to replicate some C code 
> that I am trying to port to ATS.  But, I've been scratching my head as to 
> why this would happen, so any help is appreciated.  In an effort to not 
> waste your time, I will be showing you the function with my issue along 
> with the declarations for the relevant functions & typedefs.  Please ask if 
> you'd like me to provide more details that I may have missed.
>
> The function I'm having trouble in:
>
> implement mat4_to_quat ( m ) = let
>   val tr = m.xx + m.yy + m.zz
> in
>   if tr > 0.f then let
> val s = $MATH.sqrt(tr + 1.f)
> val w = s / 2.f
> val x = ( mat4_at(m, 1, 2) - mat4_at(m, 2, 1) ) * (0.5f / s)
> val y = ( mat4_at(m, 2, 0) - mat4_at(m, 0, 2) ) * (0.5f / s)
> val z = ( mat4_at(m, 0, 1) - mat4_at(m, 1, 0) ) * (0.5f / s)
>   in
> quat_new(x, y, z, w)
>   end else let
> val nxt = @[int](1, 2, 0)
> var q = @[float][4](0.f)
> var i = 0
> var j = 0
> var k = 0
> var s = 0
>   in
> *i := ((if mat4_at(m, 1, 1) > mat4_at(m, 0, 0) then 1 else i):int);*
> *i := ((if mat4_at(m, 2, 2) > mat4_at(m, $showtype(i), i) then 2 else 
> i):int);  // <-- this line has the error*
> j := nxt[i];
> k := nxt[j];
> s := $MATH.sqrt( (mat4_at(m, i, i) - (mat4_at(m, j, j), mat4_at(m, k, 
> k))) + 1.f );
> q[i] := s * 0.5f;
> s := (if (s != 0.f) then 0.5f / s else s);
> q[3] := (mat4_at(m, j, k) - mat4_at(m, k, j)) * s;
> q[j] := (mat4_at(m, i, j) + mat4_at(m, j, i)) * s;
> q[k] := (mat4_at(m, i, k) + mat4_at(m, k, i)) * s;
> quat_new(q[0], q[1], q[2], q[3])
>   end
> end
>
>
> Here's the function's declaration:
>
> fun mat4_to_quat ( m: mat4 ) : quat = "sta#%"
>
>
> Here's the declaration for mat4_at:
>
> fun mat4_at {x:nat | x < 4}{y:nat | y < 4} ( m: mat4, x: int x, y: int y ) 
> : float = "sta#%"
>
>
> My full repo can be found here: 
> https://github.com/d4v3y5c0n3s/Goldelish-Engine
> Here's the error message:
>
> patscc -tcats /home/d4v3y/Goldelish-Engine/source/g_engine.dats
> **SHOWTYPE[UP]**(/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 
> 35508(line=1373, offs=55) -- 35509(line=1373, offs=56)): 
> S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int)): S2RTbas(S2RTBASimp(1; 
> t@ype))
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
> offs=55) -- 35509(line=1373, offs=56): error(3): the dynamic expression 
> cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6368))].
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
> offs=55) -- 35509(line=1373, offs=56): error(3): mismatch of static terms 
> (tyleq):
> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6368))
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
> offs=59) -- 35513(line=1373, offs=60): error(3): the dynamic expression 
> cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6369))].
> /home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
> offs=59) -- 35513(line=1373, offs=60): error(3): mismatch of static terms 
> (tyleq):
> The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
> The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
> S2Eextkind(atstype_int), S2EVar(6369))
>
> |
>

-- 
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/c72d1740-6551-4d66-aeea-1a148fffo%40googlegroups.com.


Issue with conditionally mutating a var twice

2020-07-16 Thread d4v3y_5c0n3s
  So, I'm trying to mutate a var twice in order to replicate some C code 
that I am trying to port to ATS.  But, I've been scratching my head as to 
why this would happen, so any help is appreciated.  In an effort to not 
waste your time, I will be showing you the function with my issue along 
with the declarations for the relevant functions & typedefs.  Please ask if 
you'd like me to provide more details that I may have missed.

The function I'm having trouble in:

implement mat4_to_quat ( m ) = let
  val tr = m.xx + m.yy + m.zz
in
  if tr > 0.f then let
val s = $MATH.sqrt(tr + 1.f)
val w = s / 2.f
val x = ( mat4_at(m, 1, 2) - mat4_at(m, 2, 1) ) * (0.5f / s)
val y = ( mat4_at(m, 2, 0) - mat4_at(m, 0, 2) ) * (0.5f / s)
val z = ( mat4_at(m, 0, 1) - mat4_at(m, 1, 0) ) * (0.5f / s)
  in
quat_new(x, y, z, w)
  end else let
val nxt = @[int](1, 2, 0)
var q = @[float][4](0.f)
var i = 0
var j = 0
var k = 0
var s = 0
  in
*i := ((if mat4_at(m, 1, 1) > mat4_at(m, 0, 0) then 1 else i):int);*
*i := ((if mat4_at(m, 2, 2) > mat4_at(m, $showtype(i), i) then 2 else 
i):int);  // <-- this line has the error*
j := nxt[i];
k := nxt[j];
s := $MATH.sqrt( (mat4_at(m, i, i) - (mat4_at(m, j, j), mat4_at(m, k, 
k))) + 1.f );
q[i] := s * 0.5f;
s := (if (s != 0.f) then 0.5f / s else s);
q[3] := (mat4_at(m, j, k) - mat4_at(m, k, j)) * s;
q[j] := (mat4_at(m, i, j) + mat4_at(m, j, i)) * s;
q[k] := (mat4_at(m, i, k) + mat4_at(m, k, i)) * s;
quat_new(q[0], q[1], q[2], q[3])
  end
end


Here's the function's declaration:

fun mat4_to_quat ( m: mat4 ) : quat = "sta#%"


Here's the declaration for mat4_at:

fun mat4_at {x:nat | x < 4}{y:nat | y < 4} ( m: mat4, x: int x, y: int y ) 
: float = "sta#%"


My full repo can be found 
here: https://github.com/d4v3y5c0n3s/Goldelish-Engine
Here's the error message:

patscc -tcats /home/d4v3y/Goldelish-Engine/source/g_engine.dats
**SHOWTYPE[UP]**(/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 
35508(line=1373, offs=55) -- 35509(line=1373, offs=56)): 
S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int)): S2RTbas(S2RTBASimp(1; 
t@ype))
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
offs=55) -- 35509(line=1373, offs=56): error(3): the dynamic expression 
cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2EVar(6368))].
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35508(line=1373, 
offs=55) -- 35509(line=1373, offs=56): error(3): mismatch of static terms 
(tyleq):
The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2EVar(6368))
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
offs=59) -- 35513(line=1373, offs=60): error(3): the dynamic expression 
cannot be assigned the type [S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2EVar(6369))].
/home/d4v3y/Goldelish-Engine/source/g_engine.dats: 35512(line=1373, 
offs=59) -- 35513(line=1373, offs=60): error(3): mismatch of static terms 
(tyleq):
The actual term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int))
The needed term is: S2Eapp(S2Ecst(g1int_int_t0ype); 
S2Eextkind(atstype_int), S2EVar(6369))

|

-- 
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/32da2a64-1760-418e-8d45-1960f16f13d5o%40googlegroups.com.


Re: Issues with SDL_mixer interface

2020-04-30 Thread d4v3y_5c0n3s
Thanks so much, this fixed the issue!

On Wednesday, April 29, 2020 at 11:59:21 PM UTC-4, Chris Double wrote:
>
> On Thu, Apr 30, 2020 at 1:28 PM d4v3y_5c0n3s  > wrote: 
> > 
> > Okay, so Mix_FadeInMusic() is still producing errors.  I will update my 
> Github repo shortly, and here are the current error messages that I am 
> receiving: 
>
> I believe this problem is because 'Mix_Music' is declared as a 
> "$extype" which represents the flat structure, so the "handle" field 
> of 'music' is a structure not a pointer. Then Creating a "var: 
> Mix_Music = m.handle" is trying to assign that flat structure to a 
> pointer. Or something like that. An easy fix (I think) is to make 
> "Mix_Music" a pointer, and change functions that use it to take it 
> directly rather than via reference: 
>
> typedef Mix_Music = ptr 
> fun Mix_FadeInMusic ( music: Mix_Music, loops: int, ms: int ) : int = 
> "mac#%" 
>
> implement audio_music_play ( m ) = let 
>   val chan = Mix_FadeInMusic(m.handle, ~1, fade_time); 
> in 
>   if (chan = ~1) then println!("unable to play music: ", Mix_GetError()) 
> end 
>
> -- 
> https://bluishcoder.co.nz 
>

-- 
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/dada99e7-7209-48d2-95ad-93e1aee57b84%40googlegroups.com.


Re: Issues with SDL_mixer interface

2020-04-29 Thread d4v3y_5c0n3s
Okay, so Mix_FadeInMusic() is still producing errors.  I will update my 
Github repo shortly, and here are the current error messages that I am 
receiving:

g_audio_dats.c: In function 'audio_music_play':
g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known
 ATStmpdec(tmpref41, Mix_Music) ;
   ^~~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
note: in definition of macro 'ATStmpdec'
 #define ATStmpdec(tmp, hit) hit tmp
 ^~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:217:29: 
error: dereferencing pointer to incomplete type 'Mix_Music' {aka 'struct 
_Mix_Music'}
 #define ATSderef(pmv, hit) (*(hit*)pmv)
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:960:22: note: in expansion of macro 'ATSSELrecsin'
 ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
atslab__handle)) ;
  ^~~~
g_audio_dats.c:960:35: note: in expansion of macro 'ATSderef'
 ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
atslab__handle)) ;
   ^~~~
make: *** [Makefile:63: obj/g_audio_dats.o] Error 1


Thank you for your help, and I will continue to investigate this issue.

On Wednesday, April 29, 2020 at 8:39:26 PM UTC-4, d4v3y_5c0n3s wrote:
>
> Yea, so, the reason that the suggestion you had for Mix_GetError() wasn't 
> working for me was that in the function definition I put "... = 
> "mac#Mix_GetError"" at the end which was causing the macro to not apply to 
> the function.  To fix this, I changed it to "... = "mac#%"", which caused 
> it to work without a hitch.  I will see if the same issue is partially 
> behind the issue I am having with Mix_FadeInMusic().
>
> On Wednesday, April 29, 2020 at 5:54:42 PM UTC-4, d4v3y_5c0n3s wrote:
>>
>> Actually, I think I've figured out (at least partially) what's wrong with 
>> my code.  I will post my results once I get the opportunity to test my 
>> theory out.
>>
>> On Wednesday, April 29, 2020 at 7:31:27 AM UTC-4, d4v3y_5c0n3s wrote:
>>>
>>>  So, I made the changes which you suggested, but unfortunately, this 
>>> didn't resolve the issues.  First, I tried modifying the macro for 
>>> Mix_GetError() in the SDL_mixer.cats file to what you suggested, but this 
>>> didn't seem to change the error message.  Perhaps I missed something, 
>>> because I don't have a solid understanding of more complex C macros.  My 
>>> changes can be seen here: 
>>> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_local.cats
>>>
>>>  Next, I tried modifying the function definition for 
>>> Mix_FadeInMusic() in SDL_mixer.sats to match your suggested modifacation, 
>>> but this didn't fix the issue.  Your suggestion is actually how I had 
>>> previously written the function, but I had changed it while experimenting 
>>> to find the cause of the issue I was encountering.  When I pushed my 
>>> changes to Github, I forgot to revert that function to what it had been 
>>> previously.  My changes can be seen here: 
>>> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats
>>>
>>> I appreciate the help, so thank you.
>>>
>>> *Here are the errors which I am currently getting after incorporating 
>>> the changes you suggested:*
>>>
>>> In file included from g_audio_dats.c:15:
>>> g_audio_dats.c: In function 'audio_sound_play':
>>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
>>> warning: assignment discards 'const' qualifier from pointer target type 
>>> [-Wdiscarded-qualifiers]
>>>  #define ATSINSmove(tmp, val) (tmp = val)
>>>^
>>> g_audio_dats.c:753:1: note: in expansion of macro 'ATSINSmove'
>>>  ATSINSmove(tmp36, Mix_GetError()) ;
>>>  ^~
>>> g_audio_dats.c: In function 'audio_music_play':
>>> g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known
>>>  ATStmpdec(tmpref41, Mix_Music) ;
>>>^~~~
>>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
>>> note: in definition of macro 'ATStmpdec'
>>>  #define ATStm

Re: Issues with SDL_mixer interface

2020-04-29 Thread d4v3y_5c0n3s
Yea, so, the reason that the suggestion you had for Mix_GetError() wasn't 
working for me was that in the function definition I put "... = 
"mac#Mix_GetError"" at the end which was causing the macro to not apply to 
the function.  To fix this, I changed it to "... = "mac#%"", which caused 
it to work without a hitch.  I will see if the same issue is partially 
behind the issue I am having with Mix_FadeInMusic().

On Wednesday, April 29, 2020 at 5:54:42 PM UTC-4, d4v3y_5c0n3s wrote:
>
> Actually, I think I've figured out (at least partially) what's wrong with 
> my code.  I will post my results once I get the opportunity to test my 
> theory out.
>
> On Wednesday, April 29, 2020 at 7:31:27 AM UTC-4, d4v3y_5c0n3s wrote:
>>
>>  So, I made the changes which you suggested, but unfortunately, this 
>> didn't resolve the issues.  First, I tried modifying the macro for 
>> Mix_GetError() in the SDL_mixer.cats file to what you suggested, but this 
>> didn't seem to change the error message.  Perhaps I missed something, 
>> because I don't have a solid understanding of more complex C macros.  My 
>> changes can be seen here: 
>> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_local.cats
>>
>>  Next, I tried modifying the function definition for 
>> Mix_FadeInMusic() in SDL_mixer.sats to match your suggested modifacation, 
>> but this didn't fix the issue.  Your suggestion is actually how I had 
>> previously written the function, but I had changed it while experimenting 
>> to find the cause of the issue I was encountering.  When I pushed my 
>> changes to Github, I forgot to revert that function to what it had been 
>> previously.  My changes can be seen here: 
>> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats
>>
>> I appreciate the help, so thank you.
>>
>> *Here are the errors which I am currently getting after incorporating the 
>> changes you suggested:*
>>
>> In file included from g_audio_dats.c:15:
>> g_audio_dats.c: In function 'audio_sound_play':
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
>> warning: assignment discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
>>  #define ATSINSmove(tmp, val) (tmp = val)
>>^
>> g_audio_dats.c:753:1: note: in expansion of macro 'ATSINSmove'
>>  ATSINSmove(tmp36, Mix_GetError()) ;
>>  ^~
>> g_audio_dats.c: In function 'audio_music_play':
>> g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known
>>  ATStmpdec(tmpref41, Mix_Music) ;
>>^~~~
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
>> note: in definition of macro 'ATStmpdec'
>>  #define ATStmpdec(tmp, hit) hit tmp
>>  ^~~
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:217:29: 
>> error: dereferencing pointer to incomplete type 'Mix_Music' {aka 'struct 
>> _Mix_Music'}
>>  #define ATSderef(pmv, hit) (*(hit*)pmv)
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
>> note: in definition of macro 'ATSINSmove'
>>  #define ATSINSmove(tmp, val) (tmp = val)
>>  ^~~
>> g_audio_dats.c:960:22: note: in expansion of macro 'ATSSELrecsin'
>>  ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
>> atslab__handle)) ;
>>   ^~~~
>> g_audio_dats.c:960:35: note: in expansion of macro 'ATSderef'
>>  ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
>> atslab__handle)) ;
>>^~~~
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
>> warning: assignment discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
>>  #define ATSINSmove(tmp, val) (tmp = val)
>>^
>> g_audio_dats.c:999:1: note: in expansion of macro 'ATSINSmove'
>>  ATSINSmove(tmp50, Mix_GetError()) ;
>>  ^~
>> make: *** [Makefile:63: obj/g_audio_dats.o] Error 1
>>
>>
>> On Tuesday, April 28, 2020 at 2:26:04 PM UTC-4, gmhwxi wrote:
>>>
>>> >>Ever since my previous question, I've been running into two issues 
>>> with my SDL_mixer bindings.  The firs

Re: Issues with SDL_mixer interface

2020-04-29 Thread d4v3y_5c0n3s
Actually, I think I've figured out (at least partially) what's wrong with 
my code.  I will post my results once I get the opportunity to test my 
theory out.

On Wednesday, April 29, 2020 at 7:31:27 AM UTC-4, d4v3y_5c0n3s wrote:
>
>  So, I made the changes which you suggested, but unfortunately, this 
> didn't resolve the issues.  First, I tried modifying the macro for 
> Mix_GetError() in the SDL_mixer.cats file to what you suggested, but this 
> didn't seem to change the error message.  Perhaps I missed something, 
> because I don't have a solid understanding of more complex C macros.  My 
> changes can be seen here: 
> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_local.cats
>
>  Next, I tried modifying the function definition for Mix_FadeInMusic() 
> in SDL_mixer.sats to match your suggested modifacation, but this didn't fix 
> the issue.  Your suggestion is actually how I had previously written the 
> function, but I had changed it while experimenting to find the cause of the 
> issue I was encountering.  When I pushed my changes to Github, I forgot to 
> revert that function to what it had been previously.  My changes can be 
> seen here: 
> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats
>
> I appreciate the help, so thank you.
>
> *Here are the errors which I am currently getting after incorporating the 
> changes you suggested:*
>
> In file included from g_audio_dats.c:15:
> g_audio_dats.c: In function 'audio_sound_play':
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
> warning: assignment discards 'const' qualifier from pointer target type 
> [-Wdiscarded-qualifiers]
>  #define ATSINSmove(tmp, val) (tmp = val)
>^
> g_audio_dats.c:753:1: note: in expansion of macro 'ATSINSmove'
>  ATSINSmove(tmp36, Mix_GetError()) ;
>  ^~
> g_audio_dats.c: In function 'audio_music_play':
> g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known
>  ATStmpdec(tmpref41, Mix_Music) ;
>^~~~
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
> note: in definition of macro 'ATStmpdec'
>  #define ATStmpdec(tmp, hit) hit tmp
>  ^~~
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:217:29: 
> error: dereferencing pointer to incomplete type 'Mix_Music' {aka 'struct 
> _Mix_Music'}
>  #define ATSderef(pmv, hit) (*(hit*)pmv)
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
> note: in definition of macro 'ATSINSmove'
>  #define ATSINSmove(tmp, val) (tmp = val)
>  ^~~
> g_audio_dats.c:960:22: note: in expansion of macro 'ATSSELrecsin'
>  ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
> atslab__handle)) ;
>   ^~~~
> g_audio_dats.c:960:35: note: in expansion of macro 'ATSderef'
>  ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
> atslab__handle)) ;
>^~~~
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
> warning: assignment discards 'const' qualifier from pointer target type 
> [-Wdiscarded-qualifiers]
>  #define ATSINSmove(tmp, val) (tmp = val)
>^
> g_audio_dats.c:999:1: note: in expansion of macro 'ATSINSmove'
>  ATSINSmove(tmp50, Mix_GetError()) ;
>  ^~
> make: *** [Makefile:63: obj/g_audio_dats.o] Error 1
>
>
> On Tuesday, April 28, 2020 at 2:26:04 PM UTC-4, gmhwxi wrote:
>>
>> >>Ever since my previous question, I've been running into two issues with 
>> my SDL_mixer bindings.  The first, is that I get a warning message whenever 
>> I use the function Mix_GetError() (the definition for this function may be 
>> found here: 
>> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats).
>>   
>> The warning is as follows:
>>
>> g_audio_dats.c: In function 'audio_sound_play': 
>>
>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
>> warning: 
>> assignment discards 'const' qualifier fr
>> om pointer target type [-Wdiscarded-qualifiers] 
>> #define ATSINSmove(tmp, val) (tmp = val)
>>
>> While this is only a warning, I would still like to know what is going 
>> wrong here.  I looked at ATS-contrib's SDL binding, and found that the 
>

Re: Issues with SDL_mixer interface

2020-04-29 Thread d4v3y_5c0n3s
 So, I made the changes which you suggested, but unfortunately, this 
didn't resolve the issues.  First, I tried modifying the macro for 
Mix_GetError() in the SDL_mixer.cats file to what you suggested, but this 
didn't seem to change the error message.  Perhaps I missed something, 
because I don't have a solid understanding of more complex C macros.  My 
changes can be seen here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_local.cats

 Next, I tried modifying the function definition for Mix_FadeInMusic() 
in SDL_mixer.sats to match your suggested modifacation, but this didn't fix 
the issue.  Your suggestion is actually how I had previously written the 
function, but I had changed it while experimenting to find the cause of the 
issue I was encountering.  When I pushed my changes to Github, I forgot to 
revert that function to what it had been previously.  My changes can be 
seen here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats

I appreciate the help, so thank you.

*Here are the errors which I am currently getting after incorporating the 
changes you suggested:*

In file included from g_audio_dats.c:15:
g_audio_dats.c: In function 'audio_sound_play':
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
warning: assignment discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 #define ATSINSmove(tmp, val) (tmp = val)
   ^
g_audio_dats.c:753:1: note: in expansion of macro 'ATSINSmove'
 ATSINSmove(tmp36, Mix_GetError()) ;
 ^~
g_audio_dats.c: In function 'audio_music_play':
g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known
 ATStmpdec(tmpref41, Mix_Music) ;
   ^~~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
note: in definition of macro 'ATStmpdec'
 #define ATStmpdec(tmp, hit) hit tmp
 ^~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:217:29: 
error: dereferencing pointer to incomplete type 'Mix_Music' {aka 'struct 
_Mix_Music'}
 #define ATSderef(pmv, hit) (*(hit*)pmv)
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:960:22: note: in expansion of macro 'ATSSELrecsin'
 ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
atslab__handle)) ;
  ^~~~
g_audio_dats.c:960:35: note: in expansion of macro 'ATSderef'
 ATSINSmove(tmpref41, ATSSELrecsin(ATSderef(arg0, Mix_Music), Mix_Music, 
atslab__handle)) ;
   ^~~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
warning: assignment discards 'const' qualifier from pointer target type 
[-Wdiscarded-qualifiers]
 #define ATSINSmove(tmp, val) (tmp = val)
   ^
g_audio_dats.c:999:1: note: in expansion of macro 'ATSINSmove'
 ATSINSmove(tmp50, Mix_GetError()) ;
 ^~
make: *** [Makefile:63: obj/g_audio_dats.o] Error 1


On Tuesday, April 28, 2020 at 2:26:04 PM UTC-4, gmhwxi wrote:
>
> >>Ever since my previous question, I've been running into two issues with 
> my SDL_mixer bindings.  The first, is that I get a warning message whenever 
> I use the function Mix_GetError() (the definition for this function may be 
> found here: 
> https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats).
>   
> The warning is as follows:
>
> g_audio_dats.c: In function 'audio_sound_play': 
> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
> warning: 
> assignment discards 'const' qualifier fr
> om pointer target type [-Wdiscarded-qualifiers] 
> #define ATSINSmove(tmp, val) (tmp = val)
>
> While this is only a warning, I would still like to know what is going 
> wrong here.  I looked at ATS-contrib's SDL binding, and found that the 
> SDL_GetError() function there had the exact same problem.  (The file for 
> this function definition may be found here: 
> https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/SDL2/SATS/SDL_error.sats
> )
>
> Here is my guess:
>
> Mx_GetError() returns a const string; but it is assigned to a variable 
> (tmp) which is not declared to be a const.
>
> I did the following:
>
> #define atscntrb_SDL2_SDL_GetError SDL_GetError
>
> which should probably be changed to the following:
>
> #define atscntrb_SDL2_SDL_GetError() ((char*)(SDL_GetError()))
>
> so as to suppress warnings like the one you encount

Issues with SDL_mixer interface

2020-04-28 Thread d4v3y_5c0n3s
 Ever since my previous question, I've been running into two issues 
with my SDL_mixer bindings.  The first, is that I get a warning message 
whenever I use the function Mix_GetError() (the definition for this 
function may be found here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats).
  
The warning is as follows:

g_audio_dats.c: In function 'audio_sound_play': 
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:35: 
warning: 
assignment discards 'const' qualifier fr
om pointer target type [-Wdiscarded-qualifiers] 
#define ATSINSmove(tmp, val) (tmp = val)

While this is only a warning, I would still like to know what is going 
wrong here.  I looked at ATS-contrib's SDL binding, and found that the 
SDL_GetError() function there had the exact same problem.  (The file for 
this function definition may be found here: 
https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/SDL2/SATS/SDL_error.sats
)

 The second issue that I'm running into has to do with my 
Mix_FadeInMusic() function (which is defined here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/SDL2/SDL_mixer.sats).
  
When I use this function, I get the following error message:

g_audio_dats.c: In function 'audio_music_play': 
g_audio_dats.c:931:11: error: storage size of 'tmpref41' isn't known 
ATStmpdec(tmpref41, Mix_Music) ; 
  ^~~~ 
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:209:33: 
note: 
in definition of macro 'ATStmpdec' 
#define ATStmpdec(tmp, hit) hit tmp 
^~~ 
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:217:29: 
error: 
dereferencing pointer to incomplete type '
Mix_Music' {aka 'struct _Mix_Music'} 
#define ATSderef(pmv, hit) (*(hit*)pmv)


 The file *where I've been receiving these errors* is available here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/source/g_audio.dats.
  
My full source code is available on Github here: 
https://github.com/d4v3y5c0n3s/Goldelish-Engine.

 Any help is appreciated, and if you'd like me to provide any more 
information, please ask for it.  Also, if anyone knows of a great resource 
for understanding how the internals of ATS work, please let me know.  I 
have a feeling that if I better understood how ATS worked, I would also 
better understand what to do when I encounter error messages such as these.

-- 
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/e3db4fac-0969-406f-aaa5-02b3b2145a84%40googlegroups.com.


Re: Declarations of external values & functions from separate file showing up as "undeclared"

2020-04-20 Thread d4v3y_5c0n3s
Yea, creating too many .sats files definitely makes things very 
complicated.  The reason I have so many is because I am re-implementing 
some C code in ATS.  My mistake here was that I did not fully understand 
the differences between a C .h file and an ATS .sats file.  Also, I avoided 
using any .hats files because documentation on them is extremely scarce.

Thank you for your reply!  This helps a lot.

On Monday, April 20, 2020 at 2:18:53 PM UTC-4, gmhwxi wrote:
>
> In general, I would say that having just a few SATS files for
> a small project is a pretty good design. A common mistake is
> to have too many SATS files, potentially creating a lot of confusion. 
>
> I almost always start with one SATS file and gradually split it if needed.
>
> Cheers!
>
> --Hongwei
>
>
>
> On Mon, Apr 20, 2020 at 2:00 PM gmhwxi > 
> wrote:
>
>>
>> I took a quick look.
>>
>> You used '#include' in many places.
>>
>> When a SATS file is included, each of the following kind of code blocks
>> is discarded.
>>
>> %{#
>> ...
>> %}
>>
>> In general, a SATS file should not be included in another file;
>> it should be staloaded. Say you have:
>>
>> foo1.sats
>> foo2.sats
>> foo3.sats
>>
>> You can then create foo_all.hats of the following content:
>>
>> #staload "foo1.sats"
>> #staload "foo2.sats"
>> #staload "foo3.sats"
>>
>> This foo_all.hats can be included in another file.
>>
>> How to fix the problem you have now?
>>
>> First, keep including SATS files as you did.
>> I suggest that you put all the code blocks of the
>> following form into a single SATS file called, say,
>> SDL2_headers.sats:
>>
>> %{#
>> ...
>> %}
>>
>> Then just make sure that this file is staloaded in a file like
>> g_audio.dats.
>>
>> By the way, you don't need to compile SATS files. You only
>> need to compile DATS files. Only when you introduce an exception
>> constructor in a SATS file, you need to compiler that SATS file.
>>
>> Hope this helps.
>>
>> On Sunday, April 19, 2020 at 3:34:15 PM UTC-4, d4v3y_5c0n3s wrote:
>>>
>>>  For roughly a week now, I've been having this issue where PATSCC 
>>> successfully typechecks my file, but when it tries to compile it to C an 
>>> error is produced due to GCC not seeing the values/functions that I am 
>>> using.  These values and functions are declared in a separate file, which 
>>> is staload-ed in properly.  After some testing, I was able to determine 
>>> that when my code was inserted into the ATS-contrib SDL library code, no 
>>> such errors were produced.  This most likely means that *the issue is 
>>> with my Makefile, and not the code itself.*  If you'd like to see my 
>>> code and/or the Makefile, it is available in my Github repository with is 
>>> linked below.
>>>
>>> For anyone who takes the time to try and answer my question, thank you 
>>> so, so much.  And if you have any questions, just let me know.
>>>
>>> *The link to my Github repo with full source code is available here: *
>>> https://github.com/d4v3y5c0n3s/Goldelish-Engine 
>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fd4v3y5c0n3s%2FGoldelish-Engine&sa=D&sntz=1&usg=AFQjCNFbdFkrZXhgKRnTUffhrwRp7dBYTg>
>>>
>>> *###  Here's the error message:  ###*
>>>
>>> In file included from g_audio_dats.c:15:
>>> g_audio_dats.c: In function 'audio_init':
>>> g_audio_dats.c:351:34: error: 'AUDIO_S16' undeclared (first use in this 
>>> function)
>>>  ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
>>>   ^
>>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
>>> note: in definition of macro 'ATSINSmove'
>>>  #define ATSINSmove(tmp, val) (tmp = val)
>>>  ^~~
>>> g_audio_dats.c:351:21: note: in expansion of macro 'ATSPMVextval'
>>>  ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
>>>  ^~~~
>>> g_audio_dats.c:351:34: note: each undeclared identifier is reported only 
>>> once for each function it appears in
>>>  ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
>>>   ^
>>> /home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
>>> note: in definition of

Declarations of external values & functions from separate file showing up as "undeclared"

2020-04-19 Thread d4v3y_5c0n3s
 For roughly a week now, I've been having this issue where PATSCC 
successfully typechecks my file, but when it tries to compile it to C an 
error is produced due to GCC not seeing the values/functions that I am 
using.  These values and functions are declared in a separate file, which 
is staload-ed in properly.  After some testing, I was able to determine 
that when my code was inserted into the ATS-contrib SDL library code, no 
such errors were produced.  This most likely means that *the issue is with 
my Makefile, and not the code itself.*  If you'd like to see my code and/or 
the Makefile, it is available in my Github repository with is linked below.

For anyone who takes the time to try and answer my question, thank you so, 
so much.  And if you have any questions, just let me know.

*The link to my Github repo with full source code is available here: *
https://github.com/d4v3y5c0n3s/Goldelish-Engine

*###  Here's the error message:  ###*

In file included from g_audio_dats.c:15:
g_audio_dats.c: In function 'audio_init':
g_audio_dats.c:351:34: error: 'AUDIO_S16' undeclared (first use in this 
function)
 ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
  ^
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:351:21: note: in expansion of macro 'ATSPMVextval'
 ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
 ^~~~
g_audio_dats.c:351:34: note: each undeclared identifier is reported only 
once for each function it appears in
 ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
  ^
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:351:21: note: in expansion of macro 'ATSPMVextval'
 ATSINSmove(tmpref3, ATSPMVextval(AUDIO_S16)) ;
 ^~~~
g_audio_dats.c:369:19: warning: implicit declaration of function 
'SDL_InitSubSystem' [-Wimplicit-function-declaration]
 ATSINSmove(tmp10, SDL_InitSubSystem(ATSPMVextval(SDL_INIT_AUDIO))) ;
   ^
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:369:50: error: 'SDL_INIT_AUDIO' undeclared (first use in 
this function)
 ATSINSmove(tmp10, SDL_InitSubSystem(ATSPMVextval(SDL_INIT_AUDIO))) ;
  ^~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:369:37: note: in expansion of macro 'ATSPMVextval'
 ATSINSmove(tmp10, SDL_InitSubSystem(ATSPMVextval(SDL_INIT_AUDIO))) ;
 ^~~~
g_audio_dats.c:401:19: warning: implicit declaration of function 
'Mix_OpenAudio' [-Wimplicit-function-declaration]
 ATSINSmove(tmp16, Mix_OpenAudio(ATSPMVi0nt(22050), 
ATSPMVextval(AUDIO_S16), ATSPMVi0nt(2), ATSPMVi0nt(4096))) ;
   ^
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c:433:19: warning: implicit declaration of function 
'Mix_QuerySpec' [-Wimplicit-function-declaration]
 ATSINSmove(tmp22, Mix_QuerySpec(ATSPMVrefarg1(ATSPMVptrof(tmpref2)), 
ATSPMVrefarg1(ATSPMVptrof(tmpref3)), ATSPMVrefarg1(ATSPMVptrof(tmpref4 ;
   ^
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:276:37: 
note: in definition of macro 'ATSINSmove'
 #define ATSINSmove(tmp, val) (tmp = val)
 ^~~
g_audio_dats.c: In function 'audio_finish':
g_audio_dats.c:669:27: warning: implicit declaration of function 
'Mix_CloseAudio' [-Wimplicit-function-declaration]
 ATSINSmove_void(tmpret25, Mix_CloseAudio()) ;
   ^~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_ccomp_instrset.h:284:39: 
note: in definition of macro 'ATSINSmove_void'
 #define ATSINSmove_void(tmp, command) command
   ^~~
g_audio_dats.c: In function 'audio_sound_play':
g_audio_dats.c:718:19: warning: implicit declaration of function 
'Mix_PlayChannel' [-Wimplicit-function-declaration]
 ATSINSmove(tmp27, Mix_PlayChannel(tmp28, 
ATSPMVrefarg1(ATSPMVptrof(ATSSELrecsin(ATSderef(arg0, Mix_Chunk), 
Mix_Chunk, atslab__sample))), arg1)) ;
   ^~~
/home/d4v3y/ATS2-Postiats-0.4.0/ccomp/runtime/pats_c

Re: "error(parsing): the keyword [:] is needed" message despite code appearing to be fine

2020-03-22 Thread d4v3y_5c0n3s
I think that was the issue.  Thanks for the help! :)

On Saturday, March 21, 2020 at 10:33:12 PM UTC-4, Richard wrote:
>
>
> Looks like the issue is from a few lines before 171, unterminated string, 
> here:
>
> fn vec2_to_array {} ( v: vec2, out: ptr ) : void = "sta#%
>

-- 
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/e5abab56-9922-4766-acbc-31d324f6b8ae%40googlegroups.com.


Re: "error(parsing): the keyword [:] is needed" message despite code appearing to be fine

2020-03-21 Thread d4v3y_5c0n3s
Nice catch.  I guess I've just been looking at the same code for too long.  
Unfortunately, fixing it doesn't resolve the problem.  I'll update my code 
on Github with that fix, and get back to it tomorrow.  By the way, thanks 
for the swift response! :D

On Saturday, March 21, 2020 at 9:14:23 PM UTC-4, Richard wrote:
>
> Hi,
>
> Missing equals sign here?
>
> fn vec2_smootherstep {} ( v1: vec2, v2: vec2, amount: vec2 ) : vec2 "sta#%"
>
>

-- 
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/42b88634-3d83-4a7f-9fd1-399e0bc34e11%40googlegroups.com.


"error(parsing): the keyword [:] is needed" message despite code appearing to be fine

2020-03-21 Thread d4v3y_5c0n3s
So, I've been encountering this "keyword [:] is needed" error, and I can't 
figure out what the issue is.  I've been compiling my code in with a 
Makefile, and I know that there are many issues the compiler would pick up 
on because much of the code is incomplete.  Here are the first errors which 
are showing up for me:

"/home/d4v3y/ATS2-Postiats-0.4.0"/bin/patscc -cleanaft --depgen --taggen 
--debug2 -I"/home/d4v3y/ATS2-Postiats-0.4.0" 
-I"/home/d4v3y/ATS2-Postiats-0.4.0"/ccomp/runtime 
-L"/home/d4v3y/ATS2-Postiats-0.4.0"/ccomp/atslib/lib -latslib -lSDL2 
-lSDL2_mixer -lSDL2_net -shared -g -lGL  -D_GNU_SOURCE -o obj/g_ui_sats.o 
-c source/g_ui.sats
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6667(line=171, offs=43) 
-- 6711(line=172, offs=42): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6662(line=171, offs=38) 
-- 6665(line=171, offs=41): error(parsing): the token is discarded.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6716(line=172, offs=47) 
-- 6761(line=174, offs=43): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6711(line=172, offs=42) 
-- 6714(line=172, offs=45): error(parsing): the token is discarded.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6766(line=174, offs=48) 
-- 6832(line=175, offs=65): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6761(line=174, offs=43) 
-- 6764(line=174, offs=46): error(parsing): the token is discarded.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6837(line=175, offs=70) 
-- 6909(line=176, offs=71): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6832(line=175, offs=65) 
-- 6835(line=175, offs=68): error(parsing): the token is discarded.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6914(line=176, offs=76) 
-- 6985(line=177, offs=70): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6909(line=176, offs=71) 
-- 6912(line=176, offs=74): error(parsing): the token is discarded.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6990(line=177, offs=75) 
-- 7110(line=182, offs=57): error(parsing): the keyword [:] is needed.
/home/d4v3y/Goldelish-Engine/source/g_engine.sats: 6985(line=177, offs=70) 
-- 6988(line=177, offs=73): error(parsing): the token is discarded.

And here is my code:

fn vec2_hash {} ( v: vec2 ) : int = "sta#%"
fn vec2_mix_hash {} ( v: vec2 ) : int = "sta#%"

fn vec2_saturate {} ( v: vec2 ) : vec2 = "sta#%"
fn vec2_lerp {} ( v1: vec2, v2: vec2, amount: float ) : vec2 = "sta#%"
fn vec2_smoothstep {} ( v1: vec2, v2: vec2, amount: float ) : vec2 = "sta#%"
fn vec2_smootherstep {} ( v1: vec2, v2: vec2, amount: vec2 ) : vec2 "sta#%"

I know that this kind of error message means that somewhere I need to 
insert some colons, but I don't know why the compiler seems to be telling 
me to place colons in the incorrect spots.  Am I missing something 
obvious?  Could it be that because my code is incomplete, there are too 
many errors and thus the compiler makes them appear in the wrong part of 
the codebase?  Any help is appreciated.  Full source code for my project is 
on github (https://github.com/d4v3y5c0n3s/Goldelish-Engine) if you'd like 
to see further details.

-- 
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/e0c5866e-af7d-4c04-bed2-f08cdeea64c2%40googlegroups.com.


Re: "fopen: No such file or directory" Issue When Compiling a Simple Project

2019-12-01 Thread d4v3y_5c0n3s
Okay, you were right.  My PATH was messed up, I had accidentally put the 
$PATSHOME variable within itself, for some reason.  Now it compiles fine.  
Thanks so much!

On Sunday, December 1, 2019 at 10:47:06 AM UTC-5, gmhwxi wrote:
>
> >> fopen(":/home/...")
>
> Where is leading ':' in the filename from?
>
> On Sun, Dec 1, 2019 at 10:40 AM d4v3y_5c0n3s  > wrote:
>
>> Hello, so I've installed ATS and I am trying to compile a simple 'hello 
>> world' program.  Here's what I enter into the terminal:
>> *patscc -o test test.dats*
>> It finds the file fine, but I keep getting this error:
>>
>> *fopen: No such file or directory exit(ATS): 
>> [fopen(":/home/d4v3y/ATS2-Postiats/prelude/fixity.ats", "r")] failed*
>> Using the 'ls' command reveals that this file, 'fixity.ats', does indeed 
>> exist, as shown below:
>> ls /home/d4v3y/ATS2-Postiats/prelude/ 
>>
>> *CATS  SATS basics_gen.sats  basics_sta.sats  fixity.ats 
>>  macrodef.sats DATS  basics_dyn.sats  basics_pre.sats  codegen2.sats 
>>lmacrodef.hats  params.hats*
>> Does anyone know what this error could be?
>>
>> -- 
>> 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-lan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/d0f270d9-4f55-43ff-940f-96b3e5dafc6a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/d0f270d9-4f55-43ff-940f-96b3e5dafc6a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/4d0040e3-eb3b-49e2-9ae8-a4a304856892%40googlegroups.com.


Re: "fopen: No such file or directory" Issue When Compiling a Simple Project

2019-12-01 Thread d4v3y_5c0n3s
Let me check my path... I'll get back to you on this.  Thanks.

On Sunday, December 1, 2019 at 10:47:06 AM UTC-5, gmhwxi wrote:
>
> >> fopen(":/home/...")
>
> Where is leading ':' in the filename from?
>
> On Sun, Dec 1, 2019 at 10:40 AM d4v3y_5c0n3s  > wrote:
>
>> Hello, so I've installed ATS and I am trying to compile a simple 'hello 
>> world' program.  Here's what I enter into the terminal:
>> *patscc -o test test.dats*
>> It finds the file fine, but I keep getting this error:
>>
>> *fopen: No such file or directory exit(ATS): 
>> [fopen(":/home/d4v3y/ATS2-Postiats/prelude/fixity.ats", "r")] failed*
>> Using the 'ls' command reveals that this file, 'fixity.ats', does indeed 
>> exist, as shown below:
>> ls /home/d4v3y/ATS2-Postiats/prelude/ 
>>
>> *CATS  SATS basics_gen.sats  basics_sta.sats  fixity.ats 
>>  macrodef.sats DATS  basics_dyn.sats  basics_pre.sats  codegen2.sats 
>>lmacrodef.hats  params.hats*
>> Does anyone know what this error could be?
>>
>> -- 
>> 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-lan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/d0f270d9-4f55-43ff-940f-96b3e5dafc6a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/d0f270d9-4f55-43ff-940f-96b3e5dafc6a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/bbaa2e9f-00d7-4ca6-9402-7af88d7b0c49%40googlegroups.com.


"fopen: No such file or directory" Issue When Compiling a Simple Project

2019-12-01 Thread d4v3y_5c0n3s
Hello, so I've installed ATS and I am trying to compile a simple 'hello 
world' program.  Here's what I enter into the terminal:
*patscc -o test test.dats*
It finds the file fine, but I keep getting this error:

*fopen: No such file or directory exit(ATS): 
[fopen(":/home/d4v3y/ATS2-Postiats/prelude/fixity.ats", "r")] failed*
Using the 'ls' command reveals that this file, 'fixity.ats', does indeed 
exist, as shown below:
ls /home/d4v3y/ATS2-Postiats/prelude/ 

*CATS  SATS basics_gen.sats  basics_sta.sats  fixity.ats 
 macrodef.sats DATS  basics_dyn.sats  basics_pre.sats  codegen2.sats 
   lmacrodef.hats  params.hats*
Does anyone know what this error could be?

-- 
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/d0f270d9-4f55-43ff-940f-96b3e5dafc6a%40googlegroups.com.


Re: Problem in Makefile: Can't Find 'atsmake-post.mk' and Other Probelms

2019-11-17 Thread d4v3y_5c0n3s
Thank you for the fast reply.  This is really helpful. :)

-- 
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/b5e5963f-b957-41a6-87ec-b3843ebd8e7f%40googlegroups.com.


Problem in Makefile: Can't Find 'atsmake-post.mk' and Other Probelms

2019-11-16 Thread d4v3y_5c0n3s
First off, I would like to say that I am new to ATS, and have been 
beginning to learn it.  I've really been enjoying it so far, and I decided 
to start a long-term project in order to help me get better at ATS.  So, I 
found the Corange game engine (https://github.com/orangeduck/Corange) and 
decided to reimplement it in ATS (
https://github.com/d4v3y5c0n3s/Goldelish-Engine).  Unfortunately, I am 
having issues figuring out how to get the Makefile properly set up.  I've 
looked at examples provided in ATS2-Postiats and ATS-Postiats-contrib.  
Basically, I'm trying to take Corange's Makefile and make it work with 
ATS.  I'm trying to figure out how Make works, and I'm starting to 
understand it, but I've been stuck due to having trouble finding answers 
online.  Currently, when I try to call 'make' on the command line I get the 
following:
Makefile:74: warning: overriding recipe for target 'testall' 
Makefile:72: warning: ignoring old recipe for target 'testall' 
Makefile:76: warning: overriding recipe for target 'testall' 
Makefile:74: warning: ignoring old recipe for target 'testall' 
Makefile:78: :/home/d4v3y/ATS2-Postiats/share/atsmake-post.mk: No such file 
or directory 
make: *** No rule to make target 
':/home/d4v3y/ATS2-Postiats/share/atsmake-post.mk'.  Stop
.
You can find my Makefile in the repo for the engine I'm working on here: (
https://github.com/d4v3y5c0n3s/Goldelish-Engine/blob/master/Makefile)
And the Makefile for Corange is here: (
https://github.com/orangeduck/Corange/blob/master/Makefile)

Thank you for any help!

-- 
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/ac6c96e9-b1d7-4d53-a90f-f93a906f4d00%40googlegroups.com.