Re: Type signatures in ATS

2021-05-29 Thread Artyom Shalkhakov
сб, 29 мая 2021 г. в 09:11, Michael Lan :

> Thank you all! That does make sense. Where can I learn more about symbols,
> and how they differ from functions etc?
>
>
It's here:

http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/c260.html

We also have a wiki on GitHub, please take a look there as well. I think
there was some info about overloading there.


> On Friday, May 28, 2021 at 11:08:55 PM UTC-7 ice.r...@gmail.com wrote:
>
>> Hi,
>> In this case, you can try `print_string`, you can see
>> prelude/SATS/string.sats for reference.
>>
>> --
> 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/32cd93be-10c2-476f-bb2c-ac35ea519499n%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/32cd93be-10c2-476f-bb2c-ac35ea519499n%40googlegroups.com?utm_medium=email_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/CAKO6%3DqhAq_yv8KLj2N_dNoGJ6%3D5-ESLugLWY3CErA-x8jWDTFA%40mail.gmail.com.


Re: Type signatures in ATS

2021-05-28 Thread artyom . shalkhakov
Hi Michael,

Welcome!

I think you need to pass one of the functions for which [print] stands for. 
It’s an overloaded symbol.

Sent from my iPhone

> On 29 May 2021, at 08:41, Michael Lan  wrote:
> 
> Hello,
> 
> New ATS learner here. The following code does not compile:
> 
> ```
> #include "share/atspre_define.hats"
> #include "share/atspre_staload.hats"
> 
> fn do_something (
>   f : string -> void
> ) : void =
> (
>   f "hi"
> )
> 
> val _ = do_something(print)
> 
> implement main0 () = ()
> ```
> 
> It says the symbol [print] cannot be resolved. I suspect it is because the 
> type of `f should somehow encode the effect. I did try `string -<1> void` as 
> well but that didn't work either. Some pointers appreciated, I am mainly 
> reading along with the ATS2 book.
> 
> Michael
> -- 
> 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/454cdb2a-7af8-40b2-8f51-48f5d67e6235n%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/6FA41377-13A5-45F4-927F-F4F68CC52946%40gmail.com.


Re: current status of libxatsopt

2021-01-23 Thread Artyom Shalkhakov
сб, 23 янв. 2021 г. в 13:45, Dambaev Alexander :

> Hi,
>
> I saw that repo and was wondering why is it using C instead of ATS2 :)
>

Well the primary reason is that C is more widely known than ATS2, which
means more people can work on it.

My optimistic plan is to provide ATS bindings to some C libraries to be
> able to implement LSP in ATS2 :) such that, some more tooling will be
> available for ATS2 as a result.
>

It can be done, BTW I worked on C very much in the style of ATS2.

As far as I understand, ideally, libxatsopt should be used to do lexical
> analyze, parser and to infer types of text buffers
>

Yes, that's a good starting point. Having that, it shouldn't be much of a
problem to implement more queries (e.g. find all references to a symbol).


> --
> 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/CAHjn2Kz59RQCX4FKDDy%2Bo6Ue7kB%2BWgV2VV-1ivGiwSsHEmN7pQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2Kz59RQCX4FKDDy%2Bo6Ue7kB%2BWgV2VV-1ivGiwSsHEmN7pQ%40mail.gmail.com?utm_medium=email_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/CAKO6%3DqhrR%3DSOokxJBk%2BOAfFwfYSYCA5yn0NQXRVydCykZOKF9w%40mail.gmail.com.


Re: current status of libxatsopt

2021-01-23 Thread Artyom Shalkhakov
Hi Alexander,

I started implementing LSP in xatslsp on GitHub but ran out of time.

You could take a look at that and I'll be glad to help you.

The initial plan was to implement some very simple things (in C) and they
work. The missing stuff is actually running ATS compiler against the text
buffers and then getting out errors. If we get errors then we can send them
as notifications to the user, that would be a great start (and this part is
mostly ATS, too). And after that we can start adding more code (in ATS) to
traverse the level-1 syntax trees for more reporting (e.g. use-def).

сб, 23 янв. 2021 г. в 05:41, Dambaev Alexander :

> Hi,
> I would like to know what is the current status of the libxatsopt.
> In particular: is it ready to be used to implement the  language server
> protocol support for ATS3?
>
> --
> 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/CAHjn2KyvpYfvLV0NfJSVt%2BbZEBcj8wtrK73Trb9ukdWRMwrmfw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KyvpYfvLV0NfJSVt%2BbZEBcj8wtrK73Trb9ukdWRMwrmfw%40mail.gmail.com?utm_medium=email_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/CAKO6%3DqijVBv8BM7KAFK1nn2ZgRNLs1jKZF1%3DA8PKD835820rwA%40mail.gmail.com.


Re: Learn ATS in Y minutes -- request for documentation review

2021-01-17 Thread artyom . shalkhakov
Hi Mark,

This is great. Thanks! I’ll take a closer look.

Надіслано з iPhone

> 17 січ. 2021 р. о 08:30 mark.l@gmail.com  пише:
> 
> 
> Hi all,
> 
> Learn X in Y Minutes has community-made documentation for programming 
> languages and tools, as example-driven "whirlwind tours" of each languages' 
> features.  I made one for ATS, since none existed and I think it's a great 
> documentation format to have.  Here's the rendered markdown, and the 
> associated PR.  It's about 500 lines of well-commented ATS, and introduces 
> language features as you read it.
> 
> I'm still relatively inexperienced in ATS, so I'd appreciate reviews to make 
> sure all the explanations are sound and to make the code more idiomatic.  
> Reviews from less experienced ATS users would also be particularly welcome, 
> to make sure it addresses the confusions you had when first using ATS.
> 
> Learn X in Y Minutes has been really helpful to me in the past learning other 
> languages, since reading good code can be a great way to learn.  I hope we 
> can make this equally helpful to new ATS programmers.
> 
> Thanks,
> 
> -Mark Barbone
> -- 
> 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/2f2cad00-f229-491a-bf7d-a064d5ec452en%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/5756F01F-FB2E-4CB0-9FE7-3C4BF0060DD3%40gmail.com.


Re: ignoring the datavtype

2020-12-30 Thread Artyom Shalkhakov
Hi Alex,

What's the type of [millis]?

ср, 30 дек. 2020 г. в 10:04, Dambaev Alexander :

> Hi all,
>
> today I spotted an error in my code. Here is the snippet:
> ```
> val millis = $BS.pack( msecs_i64 + ($UN.cast{int64} msecs)
> ) // + $UN.cast{int32} msecs )
> val env = ( hws, millis)
> val () = list_vt_foreach_funenv0< ( $BS.BytestringNSH1,
> $BS.BytestringNSH1) ><($BS.BytestringNSH1,$BS.BytestringNSH1)>{void}( () |
> kvs, env, print_json) where {
>   fn
> print_json
> ( pf: !void
> | x: &(@($BS.BytestringNSH1, $BS.BytestringNSH1))
> , env: !($BS.BytestringNSH1, $BS.BytestringNSH1)
> ): void = {
>   val (hws, millis) = env
>   val bs = $BS.pack "{ \"tenant\": \"demo\",
> \"buildingId\": \"demo\", "
> + $BS.pack "\"metadata\": { \"name\": \"" +! x.0 +
> $BS.pack "\"}, "
> + $BS.pack "\"value\": " +! x.1 + $BS.pack ", "
> + $BS.pack "\"timestamp\": " +! millis + $BS.pack
> ", "
> + $BS.pack "\"deviceId\": \"" +! hws + $BS.pack
> "\""
> + $BS.pack "}"
>   val () = $BS.printlnC( bs)
>   prval () = env := (hws, millis)
> }
> }
> *val (hws1, _) = env (* here I can just ignore the
> 'millis'  and cause a memory leak *)*
> prval () = hws := hws1
> val () = list_vt_freelin_fun<@($BS.BytestringNSH1,
> $BS.BytestringNSH1)> (kvs, cleaner) where {
>   fn cleaner( x: &($BS.BytestringNSH1, $BS.BytestringNSH1)
> >> ($BS.BytestringNSH1, $BS.BytestringNSH1)?):void = {
> val () = $BS.free x.0
> val () = $BS.free x.1
>   }
> }
> val () = $BS.free( time)
> val () = $BS.free( rawpayload)
> val () = $BS.free( hws)
> ```
> and the compiler hasn't bite my hands with this: it has typechecked and
> compiled this code without issues. Only valgrind had.
> And here is the correct snippet, which is compiling without issues as well.
>
> ```
> val millis = $BS.pack( msecs_i64 + ($UN.cast{int64} msecs)
> ) // + $UN.cast{int32} msecs )
> val env = ( hws, millis)
> val () = list_vt_foreach_funenv0< ( $BS.BytestringNSH1,
> $BS.BytestringNSH1) ><($BS.BytestringNSH1,$BS.BytestringNSH1)>{void}( () |
> kvs, env, print_json) where {
>   fn
> print_json
> ( pf: !void
> | x: &(@($BS.BytestringNSH1, $BS.BytestringNSH1))
> , env: !($BS.BytestringNSH1, $BS.BytestringNSH1)
> ): void = {
>   val (hws, millis) = env
>   val bs = $BS.pack "{ \"tenant\": \"demo\",
> \"buildingId\": \"demo\", "
> + $BS.pack "\"metadata\": { \"name\": \"" +! x.0 +
> $BS.pack "\"}, "
> + $BS.pack "\"value\": " +! x.1 + $BS.pack ", "
> + $BS.pack "\"timestamp\": " +! millis + $BS.pack
> ", "
> + $BS.pack "\"deviceId\": \"" +! hws + $BS.pack
> "\""
> + $BS.pack "}"
>   val () = $BS.printlnC( bs)
>   prval () = env := (hws, millis)
> }
> }
> *val (hws1, millis1) = env*
> prval () = hws := hws1
> *prval () = millis := millis1*
> val () = list_vt_freelin_fun<@($BS.BytestringNSH1,
> $BS.BytestringNSH1)> (kvs, cleaner) where {
>   fn cleaner( x: &($BS.BytestringNSH1, $BS.BytestringNSH1)
> >> ($BS.BytestringNSH1, $BS.BytestringNSH1)?):void = {
> val () = $BS.free x.0
> val () = $BS.free x.1
>   }
> }
> val () = $BS.free( time)
> val () = $BS.free( rawpayload)
> 

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

2020-11-02 Thread artyom . shalkhakov

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

-- 
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/D4EFE0DE-DCB9-4D79-AA78-7006FC1A3154%40gmail.com.


Re: debugging constraint error

2020-09-29 Thread Artyom Shalkhakov
_l && dynamic == l_dynamic) || (reused_l ==
>> false && dynamic == true) ]
>>   #[l:addr | (reused_l && l == l_p) || (reused_l == false && l != l_p) ]
>>   Bytestring_vtype( l_len+r_len, offset, cap, ucap, refcnt, dynamic, l)
>>
>> (* the same as append, but consumes arguments in order to make caller's
>> code clear from bunch of val's and free()
>>  *)
>> fn
>>   appendC
>>   {l_len, l_offset, l_cap, l_ucap: nat}{l_dynamic:bool}{l_p:addr}
>>   {r_len, r_offset, r_cap, r_ucap: nat}{r_dynamic:bool}{r_p:addr}
>>   ( l: Bytestring_vtype(l_len, l_offset, l_cap, l_ucap, 0, l_dynamic, l_p)
>>   , r: Bytestring_vtype(r_len, r_offset, r_cap, r_ucap, 0, r_dynamic, r_p)
>>   ):
>>
>>
>>
>>
>>
>>
>> *  [reused_l: bool | (l_ucap >= r_len && reused_l == true) || reused_l ==
>> false]  [offset:nat | (reused_l && offset == l_offset) || (reused_l &&
>> offset == 0)]  [cap:nat | (reused_l && cap == l_cap) || (cap == l_len +
>> r_len)]  [ucap:nat | (reused_l && ucap == l_ucap - r_len) || (ucap == 0)]
>> [dynamic:bool | (reused_l && dynamic == l_dynamic) || dynamic == true ]
>> [l:addr | (reused_l && l == l_p) || (reused_l == false && l != l_p) ]*
>> Bytestring_vtype( l_len+r_len, offset, cap, ucap, 0, dynamic, l)
>> ```
>>
>> DATS file:
>> ```
>> implement appendC( l, r) =
>> let
>>   val res = append( l, r)
>>   val () = free( r)
>> in
>>   if isnot_shared res (* bool (refcnt == 0), ie 5's argument of
>> Bytestring_vtype *)
>> *  then res where { (*line 299 is here *)*
>> val () = free l
>>   }
>>   else res where { val () = free( l, res) } (* consumes l, decrease recnt
>> of res *)
>> end
>> ```
>> I assume, that compiler has issues with some of bold constraints of
>> appendC function, but I am not sure as well as I am not sure how to debug
>> it other than changing constraints one by one
>>
> --
> 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/c88cedd9-dadb-43cb-a7d4-19e8e4ean%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/c88cedd9-dadb-43cb-a7d4-19e8e4ean%40googlegroups.com?utm_medium=email_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/CAKO6%3Dqgt85c2q0W%3Dws0Y7SW-iCQMyNLCVN%2B3wpxs4TdCjUxAvA%40mail.gmail.com.


Re: sizeof() operator

2020-09-27 Thread Artyom Shalkhakov
Hi Alexander,

вс, 27 сент. 2020 г. в 17:53, Dambaev Alexander :

> hi
> I was trying to create a function ptr1_add_sz, which should return a
> non-null pointer like this:
>
> ```
> fn
>   {a:viewt0ype}
>   ptr1_add_sz
>   {*l:agz*}{n:nat}{*sizeof(a) > 0*}
>   { l+n*sizeof(a) > null }
>   ( i: ptr l
>   , n: size_t n
>   ):<>
>   ptr (l+n*sizeof(a)) = ptr_add(i, n)
> ```
> the initial motivation for it is that when I have p of type ```ptr l```,
> where l has sort 'agz', ptr_add(p, 1) I don't get address, which is not
> null, so I have to prove this. For me it is obvious, that by having address
> of sort agz, natural offset and sizeof(a), then the result won't be null.
>
> ptr1_add_sz is actually typechecks, but I am not able to prove sizeof(a) >
> 0 anyhow. I was trying to use
> ```
>   val tmp:char = '0'
>   val () = assertloc( sizeof(tmp) > 0)
>   val p = ptr1_add_sz(p, i2sz(1))
> ```
> but compiler complains with:
> ```
> data/devel/ats2/bytestring/DATS/bytestring_flat.dats: 5024(line=185,
> offs=14) -- 5057(line=185, offs=47): error(3): the applied dynamic
> expression is of non-function type: S2Eapp(S2Ecst(g1uint_int_t0ype);
> S2Eextkind(atstype_size), S2Esizeof(S2Etop(knd=0; S2EVar(5399
> /data/devel/ats2/bytestring/DATS/bytestring_flat.dats: 5024(line=185,
> offs=14) -- 5057(line=185, offs=47): error(3): the dynamic expression
> cannot be assigned the type [S2Eapp(S2Ecst(g1uint_int_t0ype); S2EVar(5401),
> S2EVar(5402))].
> ```
>
> so the questions are:
> 1. is there a way to prove, that sizeof(a) > 0?
>

Probably not.


> 2. how can we use sizeof(a) operator in dynamics?
>

It's "sizeof".


> --
> 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/CAHjn2KxhqGS5QoEHj7%2Bs6wRwh1YjkOuannSJ%3D3ZaXwm4BYNOiQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KxhqGS5QoEHj7%2Bs6wRwh1YjkOuannSJ%3D3ZaXwm4BYNOiQ%40mail.gmail.com?utm_medium=email_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/CAKO6%3DqjTU3HQJQTTu-oKubAm6sUtZaPywTuKTpGOEQk6rD9CqQ%40mail.gmail.com.


Re: Garbage Collecting C objects

2020-09-26 Thread Artyom Shalkhakov
Hi Robin,

сб, 26 сент. 2020 г. в 18:13, Robin Fu :

> Recently I've been playing around porting a small subset of the gnu
> science library to ATS. Most of the work is just specifying a
> dependent/linear type wrapper around the underlying C function.
>
> But then it occured to me that explicitly allocating/freeing values though
> great for performance, is not ideal for prototyping. Is there a way for ATS
> to manage memory for C objects (that comes direcetly from C) when used in
> GC mode?
>

If you link ATS code with the Boehm GC, and you manage to instruct GSL to
use ATS GC memory allocation functions, then it might just work. Have you
tried this approach?

Here are the ATS GC memory allocation functions:

https://github.com/githwxi/ATS-Postiats/blob/master/ccomp/runtime/pats_ccomp_memalloc.h#L83

(and you need to (a) compile with -DATS_MEMALLOC_GCBDW and (b) link with
-lgc)


> The C objects that I'm working with are shown below. They are normally
> allocated with their respective allocation functions provided by the GSL C
> library.
>
>
>
> *typedef struct*
> *{*
> *size_t size;*
> *double * data; **} gsl_block;*
>
>
>
> *typedef struct *
> *{*
> *size_t size; *
> *size_t stride; *
> *double * data; *
> *gsl_block * block; *
> *int owner;**} gsl_vector;*
>
>
>
> *typedef struct*
> *{*
>
>
> *size_t size1; size_t size2; size_t tda;*
>
>
> *double * data; gsl_block * block; int owner;**} gsl_matrix;*
>
>
>
> --
> 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/b7b41717-ce6c-45fa-890c-d947c68fb894n%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/b7b41717-ce6c-45fa-890c-d947c68fb894n%40googlegroups.com?utm_medium=email_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/CAKO6%3DqhcmXQ4j5UQqaZmHT3pp9nmOV-ELVb%3DTx9gXzmGPZJkGA%40mail.gmail.com.


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

2020-09-26 Thread Artyom Shalkhakov
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_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/98a801d0-3c66-4833-9748-9b086e29bfb9n%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/98a801d0-3c66-4833-9748-9b086e29bfb9n%40googlegroups.com?utm_medium=email_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/CAKO6%3DqiMJN9g%2B9oG1kp3crUN89%2BKVgVeLkuwHCT3NG5QYyJYcQ%40mail.gmail.com.


Re: How to specify a member of function argument not greater than 1?

2020-09-18 Thread Artyom Shalkhakov
пт, 18 сент. 2020 г. в 11:51, Kiwamu Okabe :

> On Fri, Sep 18, 2020 at 5:44 PM Artyom Shalkhakov
>  wrote:
> > Perhaps try `*` instead? I mean the function mul_bool1_bool1. The `||`
> operator might be returning non-indexed bools. Yes, it's a macro:
>
> Ah! It's `+`! Thank you a lot.
>
>
> https://github.com/metasepi/postmortem/commit/ecec531d5aaa30b2b3ef90261f2124264ab98b46
>
>
Good catch! I don't know what I was thinking. :)


> > macdef || (b1, b2) = (if ,(b1) then true else ,(b2)): bool
>
> Umm... I read prelude, more
>
> Thanks,
> --
> Kiwamu Okabe at METASEPI DESIGN
>
> --
> 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/CAEvX6dkHMr8a4LSw4AHaRfReNKQh%2BNeZPMwe4CQo5c8J_%2BUCeA%40mail.gmail.com
> .
>


-- 
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/CAKO6%3Dqirwm%2BYO7s57q0EF2rszbYgXpb-4rZ_UPxaRp2f2-twXA%40mail.gmail.com.


Re: How to avoid to return uninitialized value on ATS2?

2020-09-18 Thread Artyom Shalkhakov
пт, 18 сент. 2020 г. в 02:00, Kiwamu Okabe :

> Dear Hongwei,
>
> On Thu, Sep 17, 2020 at 9:51 PM Hongwei Xi  wrote:
> > >>BTW. Can we create a polymorphic `sbuf_bcat` function to avoid
> > >>returning uninitialized value?
> >
> > You can do something like:
> >
> >absprop INITIALIZED(a:vt@ype)
> >
> >fun
> >sbuf_bcat
> >{a:vt@ype}{l:addr}
> >(pf0: INITIALIZED(a), pf1: !a @ l | p: ptr l): void = undefined()
>
> Oh, `absprop`. But...
>
> > The problem with this approach is that the user of sbuf_bcat is burdened
> with
> > the need for explicitly constructing a proof to show that 'a' is
> initialized.
>
> I can't understand this clearly.
> Should I introduce `INITIALIZED(a)` with some proof function as the user?
>

Hongwei, what does the `?` syntax stand for? Is it a type constructor? Is
it something of the sort vt0ype -> t0ype, so that, together with the
axiom(?) that any type is a viewtype with an empty view part, gives us this
behavior? Are there any special rules to it?


> Best regards,
> --
> Kiwamu Okabe at METASEPI DESIGN
>
> --
> 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/CAEvX6dmvx%3Dj%2B1cGF7%2BOSbUNXUiOuNkTvzb20MbvFDtozRynJRA%40mail.gmail.com
> .
>


-- 
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/CAKO6%3DqjVA3Xc79tCWXQr_qCXZirG%2BXuJ6oeZ4%2Bv10_Ca9McZAw%40mail.gmail.com.


A look at D templates

2020-07-31 Thread Artyom Shalkhakov
Hello all,

I have come across this article:

https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/

This makes me wonder how D templates can be compared to ATS templates?

-- 
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/4f56334e-47e8-40cb-8465-fb9b36d26d12n%40googlegroups.com.


Re: constraint solving

2020-07-25 Thread Artyom Shalkhakov
Glad you've sorted it out.

I tried using while loops and they are really complicated. Functions are
simpler to get typechecked, but then you have to thread all of that state.
Hopefully this will be much simpler with ATS3.

сб, 25 июл. 2020 г. в 08:58, Dambaev Alexander :

> ah, looks like it is because of sort of return type:
> ```
> ): size_t(oidx) =
> ```
> I had spent a day dancing around this scaffold and got it after sending a
> messge
>
> сб, 25 июл. 2020 г. в 05:54, Dambaev Alexander :
>
>> Hi,
>> I am struggling to satisfy typechecker with implementing a loop with 2
>> indexes.
>>
>> ```
>> fn
>>   encode0
>>   {n: nat}{m:nat | m > n}{l:agz}
>>   ( o_pf: !array_v(byte, l, m)
>>   | i: &(@[byte][n])
>>   , i_sz: size_t(n)
>>   , o: ptr l
>>   , o_sz: size_t(m)
>>   ): #[m1:nat | m1 <= m] size_t(m1)
>>
>> implement encode0{n}{m}( o_pf | i, i_sz, o, o_sz) = ret where {
>>   fun
>> loop
>> {iidx: nat | iidx <= n}{oidx: nat | oidx <= m}
>> ..
>> ( iidx: size_t(iidx)
>> , oidx: size_t(oidx)
>> , i: &(@[byte][n])
>> , o: &(@[byte][m])
>> ): size_t(oidx) =
>>   if iidx < i_sz
>>   then
>> if oidx < o_sz
>> then loop( iidx + 1, oidx + 1, i, o) *(* error at this line *)*
>> else oidx
>>   else oidx
>>   val ret = loop( i2sz(0), i2sz(0), i, !o)
>> }
>> ```
>> The error is follows:
>> ```
>> 1395(line=66, offs=14) -- 1426(line=66, offs=45): error(3): unsolved
>> constraint: C3NSTRprop(C3TKmain(); S2Eeqeq(S2Eapp(S2Ecst(add_int_int);
>> S2Evar(oidx(8515)), S2Eintinf(1)); S2Evar(oidx(8515
>> ```
>> For now it is just a scaffold, which I am trying to compile with a simple
>> traverse. Later I will need both iidx and oidx, but I don't understand what
>> is the issue now
>>
> --
> 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/CAHjn2KzNJ3m8%3DkXx-0KWHUMLgoGPL48v7E6VBTD9kCf9yemNMg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzNJ3m8%3DkXx-0KWHUMLgoGPL48v7E6VBTD9kCf9yemNMg%40mail.gmail.com?utm_medium=email_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/CAKO6%3Dqi9UExbi3QFftSQ9Q1Gb4Fkn3BBzzU2iSPXB8efGa%3DczA%40mail.gmail.com.


Re: unboxed datatypes

2020-07-20 Thread Artyom Shalkhakov
  val () = assertloc( !raw = 0)
>   prval () = result_pf := gw_ns_request_v1_result_clear( pf)
> }
> | _ when s < 0  => { prval result_vb_fail(pf) = result_pf
>   prval () = result_pf := gw_ns_request_v1_result_clear( pf)
> }
> }
> ```
>
> Although, I am quite satisfied with this version (well, it does not
> require custom allocator), it is still interesting why the caller of
> parse_request doesn't know about #[tag: int | tag <=
> gw_ns_request_v1_max_tag] constraint, so case+ will ask for more clauses. I
> know, that I could use intLte(gw_ns_request_v1_max_tag) type, but I need to
> something like g1intLte(tag, gw_ns_request_v1_max_tag), but this doesn't
> type checks. Any ideas how to solve this?
>
> Lot more verbose than just using datavtypes, but I haven't investigated a
> topic of custom allocator for ATS, but I guess, it is much harder
>
-- 
> 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/CAHjn2KxB1YNKbcpf_m_C8ZTOojiz-y5ae4DAyY3E4L370yPeyQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KxB1YNKbcpf_m_C8ZTOojiz-y5ae4DAyY3E4L370yPeyQ%40mail.gmail.com?utm_medium=email_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/CAKO6%3Dqg4SyiRNyrTTsdLMpLLRY-aKBc2s3RnJrFxwJuRDb%2B0SA%40mail.gmail.com.


Re: unboxed datatypes

2020-07-19 Thread Artyom Shalkhakov
ke "array of bytes of length n which
is the size of union of type A and type B". In your case, type A is int,
type B is (int, bool), and n = sizeof(union(A,B)).

If we had something like a "union" type constructor, that would have
probably made things easier for you. As I understand it, unions are
unsupported because adding them is complex and not very useful, although I
hope Hongwei will reconsider this at some point, in addition to flat array
types. :-)


> I guess, I can solve issue #1 by introducing a new sort, but I need a way
> to map sort->int values (and maybe vice verse)
>
> --
> 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/CAHjn2KzhGehaEwJ1K7h1yA7F_AUgM9yK-DXK8SxKXamN-29hjg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzhGehaEwJ1K7h1yA7F_AUgM9yK-DXK8SxKXamN-29hjg%40mail.gmail.com?utm_medium=email_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/CAKO6%3DqiB0MY01oTzt4_%3DsWtCodb%2BVVXNacrbh727pBr7v2toHg%40mail.gmail.com.


Re: unboxed datatypes

2020-07-18 Thread Artyom Shalkhakov
Hi Alex,

сб, 18 июл. 2020 г. в 09:17, Dambaev Alexander :

> Hi,
>
> datatypes/datavtypes are heap-allocated, which runtime representation, I
> guess, is a tag and a pointer to data.
>
> ATS has unboxed tuples and unboxed records, which runtime representation,
> I guess, are C's structs
>
> Is there a way to define a stack allocated datatype?
> I think, we can have them by using C's union types for runtime
> representation. Am I missing something?
>

This is not supported at the moment.

I too think it would be a great addition!

> --
> 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/CAHjn2KzsFUPptwSPgTrWVR%3DsoA42aSEmUXv4D-MAQAR_K8f%2BKw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzsFUPptwSPgTrWVR%3DsoA42aSEmUXv4D-MAQAR_K8f%2BKw%40mail.gmail.com?utm_medium=email_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/CAKO6%3DqggX%3DPE0-0FidevEnemk3JUYY6LGGD5zN5FidKNNG2Jsw%40mail.gmail.com.


Re: Issue with conditionally mutating a var twice

2020-07-16 Thread artyom . shalkhakov
Additionally, you might want to use different variables for i. It’s allowed to 
use the same variable name in successive let bindings. The different i will 
have different types, making it simpler for type checker to solve constraints.

Sent from my iPhone

> On 16 Jul 2020, at 19:01, Hongwei Xi  wrote:
> 
> 
> >> 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
> 
> 'i' is later used to index an array. 
> It seems that you just need:
> 
> 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, $showtype(i), i) then 2 else 
> i):natLt(3);
> 
> 
>> On Thu, Jul 16, 2020 at 8:12 AM 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/32da2a64-1760-418e-8d45-1960f16f13d5o%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 

Re: arrays and viewtypes

2020-07-09 Thread artyom . shalkhakov
Hi Alexander,

I guess you could also pass a reference to a stack allocated variable, but that 
would probably be very difficult to use due to proofs, initialization and the 
fact you’d be using a tuple.

Much easier to use what you’ve already found or what Hongwei describes.

Sent from my iPhone

> On 10 Jul 2020, at 04:12, Dambaev Alexander  wrote:
> 
> 
> For now, I have found the only way to achieve my goal is by using boxed 
> tuples/boxed records:
> 
> vtypedef VT = (array_v(char?,l,recv_sz) | '( ptr l, size_t recv_sz))
> (*...*)
> var tmp = (recv_buf_pf | '( recv_buf, recv_sz))
> 
> I don't know if this a best way though, as I suppose, that boxed tuple is 
> heap-allocated and I don't know how to cleanup such tuple without GC
> 
> чт, 9 июл. 2020 г. в 23:54, Dambaev Alexander :
>> And again, I had mistyped one thing in initial email:
>> 
>> (* ... *)
>> var tmp = (recv_buf_pf | recv_buf) (* var instead of val in both similar 
>> lines *)
>> (* ... *)
>> 
>> 
>> чт, 9 июл. 2020 г. в 23:47, ice.r...@gmail.com :
>>> Hi,
>>> 
>>> I am trying to understand how to use array_foreach_env function to pass to 
>>> fwork environment of more than 1 variables (of viewt@ype). 
>>> For example, I can successfully use following:
>>> 
>>> vtypedef VT = (array_v(char?, l, recv_sz | ptr l)
>>> fn walker
>>> ( array_v(pollfd_t, fdsl, nfds)
>>> , x : _t >> _
>>> , env: !VT
>>> ): void =
>>> (* body goes here *)
>>> 
>>> val tmp = (recv_buf_pf | recv_buf)
>>> val () = array_foreach_funenv
>>>
>>>{array_v(pollfd_t, fdsl,nfds)}
>>>{VT}
>>>( fds_pf | fds, nfds, walker, tmp)
>>> val (recv_buf_pf | _) = tmp
>>> 
>>> But, as soon as I want to use VT of type
>>> vtypedef VT = (array_v(char?, l, recv_sz) | ptr l, size_t recv_sz)
>>> (* ... *)
>>> val tmp = (recv_buf_pf | recv_buf, recv_sz)
>>> (* .. *)
>>> val (recv_buf_pf | _) = tmp
>>> 
>>> I am getting the following error:
>>> error(3): mismatch of sorts:
>>> the needed sort is [S2RTbas(S2RTBASimp(2; viewtype))];
>>> the actual sort is [S2RTbas(S2RTBASimp(3; viewt0ype))].
>>> 
>>> How can I fix this error? Thanks in andvance
>>> -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "ats-lang-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/ats-lang-users/A60YvQACw4c/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/6826800e-17e0-4554-8470-3a7e304bc71bn%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/CAHjn2KzgHoKJMAVypUCv17xYrB%2BFoycUySXYJknvrNVackkGqw%40mail.gmail.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/9E97682A-394E-4218-B590-EFADE0DA505B%40gmail.com.


Re: The current status of ATS3

2020-07-04 Thread Artyom Shalkhakov
On Wednesday, July 1, 2020 at 9:16:09 AM UTC+3, gmhwxi wrote:
>
> >>I'm wondering how are ATS3 templates different from ATS2 templates?
>
> Here is a simple but very telling example:
>
> fun
> 
> array_length(A0: array(a, n)): int(n)
>
> The type array(T, N) is for a C-array of size N for storing values of type 
> T.
> Given that the size information of a C-array is not attached to the array, 
> the function
> array_length can only be implemented in a context where the size 
> information can be
> obtained in some manner.
>
> In ATS3 (but not in ATS2), we can implement a template of the following 
> interface:
>
> fun
> 
> foo{n:int}(A0: array(a, n)): void
>
> In ATS2, we have to change the interface to
>
> fun
> 
> foo{n:int](A0: array(a, n), size: int(n)): void
>
> In other words, in ATS3, the size of a C-array does not have to be passed 
> together with
> the C-array; it can be "gleaned" from the context instead.
>
>
This is awesome. I'm glad you found a solution to make it work.
 

> By the way, I remember you once asked a question on the tabulate function 
> template. In
> ATS3, it can finally be properly done:
>
> fun
> 
> tabulate(): list(a, n)
>
> fun
> 
> tabulate$for{i:nat | i < n}(int(i)): a
>
> Here is some running code that could clarify further:
>
> https://github.com/xanadu-lang/xinterp/blob/master/TEST/prelude/array.dats
>
>
Yes, I remember that question. :) It's great that we can finally make the 
code modular and safe at the same time!
 

> Cheers!
>
>
>
>
>
>
> On Tue, Jun 30, 2020 at 3:39 PM Hongwei Xi > 
> wrote:
>
>> Hi Artyom,
>>
>> I will try to answer other questions later.
>>
>> >>Why are ATS3 templates more powerful than C++ templates? Could you 
>> contrast the two in some way?
>>
>> I have to say that I do not use C++ on a regular basis.
>> C++ used to be C + classes + templates. By the way, I often jokingly tell 
>> others this is what the two plusses in
>> C++ stand for :)
>>
>> C does not support inner functions. C++ used to support no inner 
>> functions. Now C++ support 'lambdas', with
>> which you can implement inner functions. But can you implement inner 
>> templates in C++?
>>
>> ATS supports embedded templates (that is, inner templates). I don't know 
>> whether C++ supports inner templates.
>> If it doesn't. then ATS is more powerful in this regard. This is a big 
>> deal because inner templates are used ubiquitously
>> in ATS library code.
>>
>> Also, with dependent types and linear types, you can do a great deal more 
>> of static checking on templates,
>> flushing out potential bugs. The introduction of features like concepts 
>> in C++ tells me that template-related
>> bugs can be quite nasty, cutting big into the benefits from using 
>> templates.
>>
>> Maybe "powerful" is not the right word. There is raw power and there is 
>> controlled power. Kind of like nuclear
>> bombs versus nuclear power plants. I was mostly talking about the latter.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Jun 30, 2020 at 2:55 PM Artyom Shalkhakov > > wrote:
>>
>>> Hi Hongwei,
>>>
>>> Thank you very much for this work!
>>>
>>> On Monday, June 29, 2020 at 9:40:33 PM UTC+3, gmhwxi wrote:
>>>>
>>>>
>>>> For those interested in ATS3.
>>>>
>>>> Before I take a break, I would like to give you an update on the
>>>> implementation of ATS3.
>>>>
>>>> To put things into some sort of perspective, let me first say a few
>>>> words on the motivation behind ATS3.
>>>>
>>>> Advised by Prof. Frank Pfenning, I did my PhD thesis on PROGRAM
>>>> VERIFICATION during my years at CMU, designing and implementing DML
>>>> (Dependently Typed ML), a programming language that extends ML with a
>>>> restricted form of dependent types. Note that DML is the predecessor of 
>>>> ATS.
>>>> These days, the dependent types in DML are often referred to as 
>>>> DML-style
>>>> dependent types in the literature (in contrast to Martin-Lof's 
>>>> dependent types
>>>> that were originally invented for creating a type-theoretic foundation 
>>>> for Mathematics).
>>>>
>>>> As you can see, there are two words in PROGRAM VERIFICATION. One must
>>>> talk about program construction when talking about program
>>>

Re: The current status of ATS3

2020-06-30 Thread Artyom Shalkhakov
Hi Hongwei,

Thank you very much for this work!

On Monday, June 29, 2020 at 9:40:33 PM UTC+3, gmhwxi wrote:
>
>
> For those interested in ATS3.
>
> Before I take a break, I would like to give you an update on the
> implementation of ATS3.
>
> To put things into some sort of perspective, let me first say a few
> words on the motivation behind ATS3.
>
> Advised by Prof. Frank Pfenning, I did my PhD thesis on PROGRAM
> VERIFICATION during my years at CMU, designing and implementing DML
> (Dependently Typed ML), a programming language that extends ML with a
> restricted form of dependent types. Note that DML is the predecessor of 
> ATS.
> These days, the dependent types in DML are often referred to as DML-style
> dependent types in the literature (in contrast to Martin-Lof's dependent 
> types
> that were originally invented for creating a type-theoretic foundation for 
> Mathematics).
>
> As you can see, there are two words in PROGRAM VERIFICATION. One must
> talk about program construction when talking about program
> verification. Originally, the kind of programs I intended to verify
> were supposedly written in an ML-like language. But it soon (even
> before 2008) became very clear to me that such a language badly lacks
> meta-programming support. And I immediately started to improvise. I
> first added some support for templates into ATS1 and then strengthened
> it in ATS2.  Unfortunately, the kind of support for templates in ATS2
> was in direct conflict with the support for dependent types. The
> original primary motivation for ATS3 was to eliminate this (crippling)
> conflict.
>
> Up to ATS2, I mostly did language implementation for the purpose of
> experimenting with a variety of programming features. At this point, I
> no longer feel that I have time and/or energy to continue
> experimenting. Compared to ATS2, I re-designed the implementation of
> ATS3 to make it much more modular so as to better support future
> changes and additions. I intend for ATS3 to eventually become a language
> of production quality.
>
> ATS3 is implemented in ATS2. There are three big components planned
> for ATS3: program construction (Part I), program compilation (Part 2),
> and program verification (Part 3).
>
> ##
>
> Part 1:
>
> At this moment, I have nearly finished Part I.
>
> This part covers type inference (involving only ML-style algebraic
> types) and template resolution (this is, replacing template instances
> with proper template-free code).  There is currently a rudimentary
> interpreter available for interpreting programs constructed in ATS3. I
> have also being implementing a template-based prelude library for
> ATS3.
>

I'm wondering how are ATS3 templates different from ATS2 templates?


> Part 2:
>
> I will soon be starting to work on Part 2 after taking a break, hoping
> to finish something that can be tested at the end of the Summer.
>
> Part 3:
>
> This part essentially does type-checking involving linear types and
> dependent types. Hopefully, I will be able to get a running implementation
> by the Spring next year.
>
> ##
>
> Based on what I have experimented so far, I find the current support
> for templates in ATS3 to be a game-changing programming feature that
> can greatly increase one's programming productivity. I am a bit amazed
> by it :) If you think that the templates in C++ are powerful, then you
> will find that the templates in ATS3 are even more powerful in many
> aspects. Actually, not only just more powerful but also a great deal
> safer. Keep tuned.
>
>
Why are ATS3 templates more powerful than C++ templates? Could you contrast 
the two in some way?
 

> 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/8fb6bfae-872a-416a-8ad2-4e1281161ebfo%40googlegroups.com.


Re: ATS2 libraries I've been working on

2020-06-25 Thread Artyom Shalkhakov
Hi Randy and welcome!

This is nice!

I think I might find these things very handy one day!

On Thursday, June 25, 2020 at 2:35:33 AM UTC+3, randy...@gmail.com wrote:
>
>
> First of all, I'd like to say hello to everyone. This is my first post 
> (please be kind). 
>
> I've been playing with ATS for the last few months and I wanted to share 
> some libraries that I've been working on. A few things to note before 
> criticism is laid upon me: 
>
> 1. I definitely am still learning ATS, so I've probably (definitely?) made 
> many mistakes. 
> 2. These libraries still need work (like a license, documentation, more 
> features, so on).
>
> https://github.com/xran-deex/ats-http (a basic (but working!) http server 
> built on epoll)
> https://github.com/xran-deex/ats-args (a command line parsing library)
> https://github.com/xran-deex/ats-unit-testing (a tiny unit testing 
> framework)
> https://github.com/xran-deex/ats-threadpool
> https://github.com/xran-deex/ats-epoll (ats-http is built on top of this)
>
> All of these libraries *should* be memory clean and have a small test 
> suite accompanying them (using ats-unit-testing).
>
> My main focus has been the HTTP library. It's far from a full 
> implementation of the protocol, but it works quite well, it handles basic 
> get, post, put requests, does gzip compression, access to headers and 
> request body, and there's an example using sqlite3. Also, it's pretty fast 
> and the binary is tiny (2 of my main goals with the project).
>
> There are a bunch of other smaller libraries that each of these projects 
> depend on (some of which I think are borrowed (stolen?) from elsewhere and 
> modified to work with my makefiles). 
> To make things simple, I've defaulted to using npm to manage dependencies.
> I have a docker image (xrandeex/ats2:0.4.0) that most of my libraries use 
> in conjunction with drone.io to automate builds when checking into 
> github. 
>
> Enjoy!
> -Randy
>

-- 
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/a3d2e7ae-1c70-42e5-9bb8-08d51ea332e6o%40googlegroups.com.


Re: HOAS encoding of lambda calculus with linear types

2020-06-07 Thread artyom . shalkhakov

> On 7 Jun 2020, at 22:31, August Alm  wrote:
> 
> 
> Thanks for commenting, Artyom!
> 
> Yeah, I tried the !-modality. I even tried the ?! and the `dataget` castfn. 
> Can't get it to work.
> As you may guess I'm also hoping to implement a parser of lambda-expressions 
> to abstract
> syntax terms. For that I think I need to be able to write, e.g., something 
> like
> 
> val twice = Lam(s, lam(t) => App(t, t))

Yes, I see the problem now. I think you will have to use reference counting or 
deep copying... but I guess these are the manual workarounds you mentioned?

> [lam(t) => App(t, t)] is not a valid [!term_vt - term_vt]. Of 
> course, if I wanted to
> duplicate like that I could achievie it by manual work-arounds, I think, but 
> it would be hard
> to automate during parsing. (It would show up parsing `lam x.x(x)` ..)

What do you mean by automating during parsing?

> Much of the point of
> the HOAS-route is to make parsing easy. No need for de Bruijn. That and 
> speed, assuming
> ATS is fast at closure conversions.
> 
>> Den söndag 7 juni 2020 kl. 21:08:02 UTC+2 skrev artyom.s...@gmail.com:
>> Hi August,
>> 
>> This is interesting stuff you’re working on. :)
>> 
 On 7 Jun 2020, at 15:19, August Alm  wrote:
 
>>> 
>>> Hi!
>>> 
>>> For fun, I implemented an interpreter of the untyped lambda calculus
>>> in ATS2, using "higher order syntax" (HOAS). HOAS here means that
>>> everything proceeds from the following datatype encoding of an abstract
>>> syntax term:
>>> 
>>> datatype
>>> term_t = 
>>>   | Var of string
>>>   | Lam of (string, term_t - term_t)
>>>   | App of (term_t, term_t)
>>> 
>>> So, it uses the function type [term_t - term_t] of the host 
>>> language,
>>> ATS2 in this case, to encode lambda-terms. For example, the identity 
>>> function
>>> `lam x. x` would be encoded as the term
>>> 
>>> Lam("x", lam(t) => t)
>>> 
>>> It all worked out nicely. Then I tried to do the same thing with linear 
>>> types,
>>> to get an implementation that does not require garbage collection. I started
>>> out like this:
>>> 
>>> datavtype
>>> term_vt =
>>>   | Var of strptr
>>>   | Lam of (strptr, term_vt - term_vt)
>>>   | App of (term_vt, term_vt)
>>> 
>>> I got all the functions working and started doing some tests and discovered
>>> that this of course (*face palm*) does not work as I intended. It 
>>> essentially
>>> encodes _linear_ lambda calculus because the `cloptr` type here will not 
>>> admit
>>> things like duplication; one cannot write terms like
>>> 
>>> Lam("z", lam(t) => App(t, t)) .
>>> 
>>> Any suggestions? What one needs is something that behaves like [term_t],
>>> above, but is such that all nodes of the abstract syntax tree can be 
>>> manually
>>> freed and are considered linear by the type-checker, so that one gets the
>>> appropriate warnings if one forgets to do so. I guess I could try to do it 
>>> all with
>>> (data)views and pointers, no dataviewtypes, but I'm wary of doing so since 
>>> the
>>> complexity of doing something as simple as linked lists that way is already
>>> considerable.
>>> 
>> 
>> Could you try (!term_vt) - term_vt instead? That means that the 
>> closure function will preserve the argument passed to it, and that it may 
>> use the argument many times.
>> 
>> Also in your code below for printing, you could use the same modality so the 
>> printer doesn’t discard the AST!
>> 
>>> A more concrete question is: How exactly is the type [a - b] 
>>> defined?
>> 
>> I think that it will correspond to a C function with an extra pointer 
>> argument for holding the environment (i.e. all the captured variables).
>> 
>>> Can it explicitly as "(view | type)"? How is it related to [a - b]? 
>>> Searching
>>> the code of the ATS2 repo on Github I can only find the type [cloptr(a)] 
>>> which
>>> mysteriously to me, has a single type parameter.
>> 
>> There was some documentation on this here:
>> 
>> http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/c1220.html
>> 
>> This probably doesn’t answer all of your questions, though.
>> 
>>> 
>>> Best wishes,
>>> August
>>> 
>>> Ps. Below is complete code for the linear version that doesn't quite work as
>>> intended, but compiles just fine and runs memory-safely. I compile with:
>>> 
>>> $ patscc -O2 -flto -D_GNU_SOURCE -DATS_MEMALLOC_LIBC main.dats -o main 
>>> -latslib
>>> 
>>> (* * * *)
>>> 
>>> #include "share/atspre_define.hats"
>>> #include "share/atspre_staload.hats"
>>> staload UN = "prelude/SATS/unsafe.sats"
>>> 
>>> (* * * *)
>>> 
>>> // Our type-to-be of the abstract syntax trees.
>>> absvtype
>>> term_vt = ptr
>>> 
>>> // Linear function type.
>>> vtypedef
>>> end_vt = term_vt - term_vt
>>> 
>>> // Note: Linear closures want to be evaluated before
>>> // they are freed with this macro.
>>> macdef
>>> free_end(f) = cloptr_free($UN.castvwtp0(,(f)))
>>> 
>>> // HOAS encoding of untyped λ-calculus.
>>> datavtype
>>> term_vtype =
>>>   | Var of strptr
>>>   | Lam of (strptr, end_vt)
>>>   

Re: atscc doesn't compile hello world

2020-02-26 Thread Artyom Shalkhakov
Hi Temirkhan,

Please use "patscc" instead of "atscc".

ср, 26 февр. 2020 г. в 18:40, Temirkhan Myrzamadi :

> I've installed ATS by typing the following commands:
>
> ```
> sudo apt install ats2-lang
> sudo apt install ats-lang-anairiats
> ```
>
> My learn.dats file:
>
> ```
> implement
> main0 () = print("Hello, world!\n")
> ```
>
> But atscc cannot compile it:
>
> ```
> $ atscc -o hello learn.dats
> /usr/lib/ats-anairiats-0.2.11/bin/atsopt --output learn_dats.c --dynamic
> learn.dats
> /home/hirrolot/learn.dats: 13(line=4, offs=1) -- 48(line=4, offs=36):
> error(2): the dynamic identifier [main0] is unrecognized.
> exit(ATS): uncaught exception:
> ATS_2d0_2e2_2e11_2src_2ats_error_2esats__FatalErrorException(1027)
> ```
>
> The atscc version:
>
> ```
> $ atscc --version
> ATS/Anairiats version 0.2.11 with Copyright (c) 2002-2013 Hongwei Xi
> gcc -I/usr/lib/ats-anairiats-0.2.11/
> -I/usr/lib/ats-anairiats-0.2.11/ccomp/runtime/
> -L/usr/lib/ats-anairiats-0.2.11/ccomp/lib64/
> /usr/lib/ats-anairiats-0.2.11/ccomp/runtime/ats_prelude.c --version -lats
> gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> ```
>
> My OS:
>
> ```
>hirrolot@hirrolot-desktop
>  Mmds+.OS: Mint 19.1 tessa
>  MMm::-://oymNMd+` Kernel: x86_64 Linux
> 4.15.0-20-generic
>  MMd  /++-sNMd:Uptime: 5h 42m
>  MMNso/`  dMM`.::-. .-::.` .hMN:   Packages: 2194
>  MMh  dMM   :hNMNMNhNMNMNh: `NMm   Shell: bash 4.4.20
>  NMm  dMM  .NMN/-+MMM+-/NMN` dMM   Resolution: 2560x1440
>  NMm  dMM  -MMm  `MMM   dMM. dMM   DE: Cinnamon 4.0.10
>  NMm  dMM  -MMm  `MMM   dMM. dMM   WM: Muffin
>  NMm  dMM  .mmd  `mmm   yMM. dMM   WM Theme: Mint-Y-Dark (Mint-Y)
>  NMm  dMM`  ..`   ...   ydm. dMM   GTK Theme: Mint-Y [GTK2/3]
>  hMM- +MMd/---...-:sdds  dMM   Icon Theme: Mint-Y
>  -NMm- :hNMNNNmdy/`  dMM   Font: Noto Sans 9
>   -dMNs-``----.``dMM   CPU: Intel Core i7-6700 @ 8x 4GHz
> [44.0°C]
>`/dMNmy+/:-:/yMMM   GPU: NV136
>   ./ydNM   RAM: 3086MiB / 7927MiB
>  \.MMM
>
> ```
>
> I guess that I have an old version of ATS. How can I fix it?
>
> --
> 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/b84b962a-1ba5-448b-8150-076dfcd987b0%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/b84b962a-1ba5-448b-8150-076dfcd987b0%40googlegroups.com?utm_medium=email_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/CAKO6%3DqhijVMG1xXfAxfdgfZR7gigg5Yn5bJDGnLVT0huWjebaA%40mail.gmail.com.


Re: Referential transparency in ATS

2019-08-18 Thread Artyom Shalkhakov
On Sunday, August 18, 2019 at 7:10:26 AM UTC+3, Brandon Barker wrote:
>
> Hi Artyom - would you mind sharing the repo URL, assuming it is open?
>
>
Well, here it is:

https://github.com/ashalkhakov/libatsc
 

> On Thursday, August 8, 2019 at 2:49:43 AM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hi Brandon, Alexander,
>>
>> On Wednesday, August 7, 2019 at 5:31:04 AM UTC+3, Brandon Barker wrote:
>>
>>> I just want to say this is quite intriguing, I think it would be very 
>>> appealing to have a standard library built on this idea (a modification of 
>>> Temptory?), perhaps with some more fleshed out examples of IO splits before 
>>> really digging in.
>>>
>>
>> I'm writing such a library in my spare time, but I find that HX did most 
>> of the work back in ATS0/ATS1 days.
>>
>> Getting back to the problem Alexander mentioned, we could try using 
>> fractional permissions. I'll take an array as an example.
>>
>> We could still try to use fractional permissions (similarly to what is 
>> described here 
>> <http://www.cs.uwm.edu/faculty/boyland/papers/iterators.pdf>, PDF)
>>
>>- a collection gets one more type index, k:int (k >= 0)
>>- k stands for fraction 2^(-k) (e.g. k=0 is 1, k=1 is 1/2, etc.)
>>
>> Let's make a fractional dynamically-resizeable array:
>>
>> absview farray_v(a:vtflt, l:addr, n:int, k:int)
>>
>> Examples:
>>
>> farray_v(a,l,n,0) <- whole permission to array, allows writing!
>> farray_v(a,l,n,k) <- k > 0, this is a read-only permission, can't reassign
>>
>> Basically, it's OK to *split* the view in half.
>>
>> praxi split : {a:vtflt}{l:addr}{n:int}{k:nat} farray_v(a,l,n,k) -> 
>> (farray_v(a,l,n,k+1), farray_v(a,l,n,k+1))
>> praxi unsplit : {a:vtflt}{l:addr}{n:int}{k:pos} (farray_v(a,l,n,k), 
>> farray_v(a,l,n,k)) -> farray_v(a,l,n,k-1)
>>
>> Allocation and deallocation only deal with the whole permission:
>>
>> fun{a:tflt}
>> farray_free {l:addr;n:int} (farray_v(a,l,n,0) | ptr l): void
>> fun{a:vtflt}
>> farray_alloc (capacity: int): [l:addr] (farray_v(a,l,0,0) | ptr l)
>>
>> Now we can imagine that some array operations are destructive, so we 
>> require k=0 for the view, but the read-only operations can be used with any 
>> k.
>>
>> fun{a:tflt}
>> farray_get_at {l:addr;n:int;k:int;i:nat | i < n} (!farray_v(a,l,n,k) | 
>> ptr l, int i): a
>> fun{a:vtflt}
>> farray_insert_before {l:addr;n:int;k:int;i:nat | i <= n} 
>> (!farray_v(a,l,n,0) >> farray_v(a,l,n+1,0) | ptr l, int i, a): void
>>
>> Basically:
>>
>>- destructive operations can only be called if you have the whole 
>>permission (i.e. k=0)
>>- destructive operations are: insert, append, prepend, delete
>>
>> However, if we are to give safe types to C++-style iterators, we'd still 
>> need lots more precision... It isn't enough to have an farray(a,n), you 
>> have to ensure that the iterator is from *this* array not *that* array. 
>> This will be very painful to work with. I'll sketch out an iterator API 
>> below.
>>
>> // basically a pointer to array element (but may point past the end of 
>> array: this is the "end" iterator)
>> absvtbox
>> fiter (a:vtflt,l:addr,k:int,b:bool) // b=true: this is the end iterator, 
>> i.e. it can't be read from/written to
>>
>> // simple pointer equality
>> fun
>> eq_fiter {a:vtflt}{l:addr}{k1,k2:int} (!fiter(a,l,k1,b1), 
>> !fiter(a,l,k2,b2)): bool (b1 == b2)
>>
>> // taking pointers out
>> fun{a:vtflt}
>> farray_begin {l:addr}{n:int}{k:int} (!farray_v(a,l,n,k) >> 
>> farray_v(a,l,n,k+1) | ptr l): [b:bool] fiter(a,l,k+1,b)
>> fun{a:vtflt}
>> farray_end {l:addr}{n:int}{k:int} (!farray_v(a,l,n,k) >> 
>> farray_v(a,l,n,k+1) | ptr l): fiter(a,l,k+1,true)
>>
>> // putting pointers back
>> prfun
>> fiter_putback {a:vtflt}{l:addr}{n:int}{k:pos}{b:bool} (!farray_v(a,l,n,k) 
>> >> farray_v(a,l,n,k-1), fiter(a,l,k,b)): void
>>
>> fun{a:vtflt}
>> fiter_succ {l:addr}{k:int} (fiter(a,l,k,b)): fiter(a,l,k,b)
>> fun{a:vtflt}
>> fiter_pred {l:addr}{k:int} (fiter(a,l,k,b)): fiter(a,l,k,b)
>> fun{a:tflt}
>> fiter_get {l:addr}{k:int} (!fiter(a,l,k,false)): a
>> fun{a:tflt}
>> fiter_set {l:addr}{k:int} (!fiter(a,l,k,false), a): void
>>
>> For trees, it's going to be pretty similar, I think: if you have parent 
>> links in this tree, then an iterator is again simply a pointer, and the 
>&

Re: Referential transparency in ATS

2019-08-08 Thread Artyom Shalkhakov
 unmatched.
>>
>> On Thursday, March 21, 2019 at 1:28:42 PM UTC-4, Brandon Barker wrote:
>>>
>>>
>>>
>>> On Thursday, March 21, 2019 at 9:30:40 AM UTC-4, Brandon Barker wrote:
>>>>
>>>> Hi Artyom,
>>>>
>>>> I'm also grappling with the issue of RT in this case as I'd so far only 
>>>> thought about it in terms of function calls, but what you and Vanessa say 
>>>> helped me to understand the issue. Though I haven't managed to get ATS to 
>>>> have the same behavior as OCaml in the "let expression" above, I suspect 
>>>> it 
>>>> is possible. The key phrase here seems to be "side-effecting expression", 
>>>> and relates to the fact that functions in ATS can perform side effects 
>>>> without having any effect type or IO monad ascribed to the value (again, 
>>>> iirc).
>>>>
>>>
>>> Well, maybe that isn't the real key - the real key, I now think, is that 
>>> ATS doesn't (by default?) model an IO effect. In section 6.9 of 
>>> http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/PDF/main.pdf it 
>>> is mentioned that using both linear and dependent types may be used to do 
>>> this, though I think the suggestion here is for more than printing to e.g. 
>>> STDOUT. 
>>>
>>> If anyone has looked at modeling/enforcing an IO-like effect type in 
>>> ATS, I'd be interested to see it.
>>>
>>>>
>>>> Perhaps tonight I should try out the same in Idris or PureScript, which 
>>>> are not lazily evaluated by default but do use IO, to get a better 
>>>> understanding.
>>>>
>>>> On Thursday, March 21, 2019 at 3:17:46 AM UTC-4, Artyom Shalkhakov 
>>>> wrote:
>>>>>
>>>>> Hi Brandon,
>>>>>
>>>>> Admittedly I don't really understand what RT is, but from what I 
>>>>> understand, in Haskell the expression like [print "ha"] is basically a 
>>>>> command to the top-level interpreter (which is the language runtime) to 
>>>>> perform an effect on the console (moreover, it will be evaluated on 
>>>>> as-needed basis). Moreover, the ";" is itself another comand, the 
>>>>> explicit 
>>>>> sequencing command, the meaning of which is "perform the left-hand side 
>>>>> effects, then perform the right-hand side effects". Such a command is a 
>>>>> value, so it can be passed as a value and reused as many times as is 
>>>>> necessary. In ATS, the expression like [print "ha"] evaluates right there 
>>>>> to a void/"no value", and the ";" is also NOT a value at all, but rather 
>>>>> a 
>>>>> "shortcut" syntax to a "let-in-end" form.
>>>>>
>>>>> I like to imagine an interpreter that sits in the Haskell's runtime. 
>>>>> Values of IO type are commands to this interpreter. Typical Haskell 
>>>>> IO-based programs are building up these commands as they are being 
>>>>> evaluated by the runtime. The runtime starts evaluation at the "main" 
>>>>> expression defined by the programmer.
>>>>>
>>>>> чт, 21 мар. 2019 г. в 03:45, Brandon Barker :
>>>>>
>>>>>> I'm a little rusty, so can't come up with many good examples.
>>>>>>
>>>>>> Apparently it is possible to do something like this in OCaml:
>>>>>>
>>>>>> implement
>>>>>> main0 () = {
>>>>>>   val () = let
>>>>>> val ha = print("ha")
>>>>>>   in
>>>>>> (ha; ha) // How to get two ha's here?
>>>>>>   end
>>>>>> }
>>>>>>
>>>>>>
>>>>>> After running the program, you would only see one "ha", which 
>>>>>> violates RT.
>>>>>>
>>>>>> However, ATS doesn't seem to allow a sequence expression in the "in" 
>>>>>> position of a let expression, as this doesn't compile. Admittedly I'm 
>>>>>> just 
>>>>>> trying to see if ATS2 doesn't have RT in this particular case, but it 
>>>>>> would 
>>>>>> also be good to know about the sequence expressions here.
>>>>>>
>>>>>> -- 
>>>>>

Re: An interesting talk on ATS

2019-06-30 Thread Artyom Shalkhakov
On Sunday, June 30, 2019 at 6:05:42 PM UTC+3, gmhwxi wrote:
>
>
> Here it is:
>
> https://www.reddit.com/r/ATS/comments/c5xdtp/a_tase_of_ats/
>
>
Thanks for posting it here. I watched it a few days ago and it's very well 
put. Thanks Aditya!
 

> Kudos to Aditya Siram!
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/4a7c258e-81c3-4485-bb72-755c00481e2a%40googlegroups.com.


Re: Temptory Docs Website

2019-06-02 Thread Artyom Shalkhakov
Hi Richard,

Awesome, thank you so much for doing this!

What help do you need?

On Mon, Jun 3, 2019, 05:25 Richard  wrote:

> Hello all,
>
> Just a sneak peak of something I have been working on for documenting
> ATS-Temptory.
>
> https://sparverius.github.io/tmplats-doc/
>
> - Richard
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/6a68507a-bb2e-4e80-a560-089c3d6bf81e%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqizMM5QsrjLqD2JvGFoT5dFTCRnoam4GXbUhhk2wjkY4A%40mail.gmail.com.


Re: Consume all linear props of a given form in the environment?

2019-06-01 Thread Artyom Shalkhakov
Hi Shimin and welcome!

For me ATS is a place where I can bring some dry linear logic calisthenics 
to life with programming. So let's get started.

On Saturday, June 1, 2019 at 2:33:37 AM UTC+3, Shimin Guo wrote:
>
> I'm thinking of using linear types for system administration. 
> Specifically, I want to add type annotations to commands like mkdir, rm, 
> etc., so I can reason about the state of the system after they are executed.
>
> For example, mkdir will have the type
>
> p: path -> isdir(p)
>
> where isdir(x) is a linear prop. rmdir will consume that prop.
>
> What I'm currently stuck on is the following scenario:
>
> touch a/b/c
> rm -r a
>
> After the touch, there should be a linear prop exists(a/b/c), and after 
> the rm, the linear prop needs to be consumed. My question is, what should 
> the type signature for "rm -r " be? It seems it needs to consume all 
> the linear props in the "environment" in the form of exists(p) where p is 
> under . Is there a way to represent such a signature in a language 
> like ATS?
>

I think it would make sense to somehow "leave" b and c to "be", i.e. 
discard the handles to them but leave them as-is in the filesystem. That 
could be a no-op function, even, but of course, for total correctness you 
don't want any other process to have links to b or c... So as you can see, 
it gets a bit problematic. However, putting this scenario aside, you could 
have a function to "free" the handles, then use it to dispose of the 
handles, and then finally remove a. I once wrote a variadic macro that 
helped me to clear out such linear-typed variables in one line.

Here are a few rambling thoughts about your problem. Please take with a 
grain of salt. It's really complicated to do this as I describe below (with 
the indexes), but might give some ideas.

We could represent the filesystem as labelled tree (every label is the file 
or directory name). Directories may contain subdirectories and files (files 
cannot be nested). So it can be seen as a graph, where files/directories 
are two sorts of nodes, and containment relation between any two nodes are 
the edges. Then a path is just a sequence of steps through the tree nodes, 
same as in graph theory. For example, a is a node of sort "directory", b is 
a node of sort "directory", b is contained in a, c is a node of sort 
"file", c is contained in b, and also, the file path a/b/c is a sequence of 
steps, starting at a, following through the "contained in" relationship 
between nodes, and ending at "c".

Since it makes sense to think of these nodes as resources, then we 
represent these with linear types. Then we are left with the containment 
relation.

Imagine we have an abstract linear type fsnode(bool) where fsnode(true) is 
assigned to files and fsnode(false) is assigned to directories. We could 
also introduce some casts if we wanted to (e.g. introduce a type "file" 
that is convertible to fsnode(true) and vice versa, and a type "directory" 
that is convertible to fsnode(false) and vice versa).

One way to deal with it is to index every node with an integer denoting the 
count of subdirectories/files that it contains. Then you'd have an 
fsnode(bool,int), where the second index is the count of 
subdirectories/files that are contained in the directory (for files it 
would be always 0, of course). This kind of solution is not very practical, 
though. So another approach could be to track in the indexes two more bits 
of information about the node:

1. the identity of a node (as something opaque, e.g. an addr index)
2. the identity of a node's parent

Then for a root directory node you'd have a type like fsnode(false, p, 
null) where p is some non-null address, And for a subdirectory that's under 
the root directory you'd have have a type like fsnode(false, p1, p), that 
is, it's contained in p, and p1 is not the same as p (this would be usually 
discharged by the typechecker, we don't really care about it).

So in your case, it would go like this, in code:

val r = fs_root () // : fsnode(false, r, null)
val a = mkdir (r, "a") // : fsnode(false, a, r)
val b = mkdir (a, "b") // : fsnode(false, b, a)
val c = mkdir (b, "c") // : fsnode(false, c, b)
val () = free (c) // [c] is no more in our code
val () = free (b) // [b] is no more in our code
val () = rm (a, true(*recursive*)) // [a] is removed, recursively
val () = free (r) // we don't need [r] anymore

The "free" and "fs_root" are more like "leasing" the resources from OS 
(i.e. asking for them to use temporarily, but then eventually we are 
obliged to give them back to their justful owner).

Since these functions that we give to the user are the only way to 
legitimate work with the abstract types, they will have to comply with the 
protocol that we impose on them, or their program will fail to compile.

A similar approach is taken below (please see the provided tests, too, 
since they are actual programs you can run):


Re: Idea for new logo

2019-05-31 Thread Artyom Shalkhakov
On Thursday, May 30, 2019 at 9:06:57 PM UTC+3, Richard wrote:
>
> https://raw.githubusercontent.com/sparverius/ats-logo/master/ats.png
>

I like this.

We could also update the current logo e.g. add some shadows. :) 
Unfortunately I'm not good at graphic design.

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/4eef0980-a2a9-4a6d-afd3-64f2abeeba87%40googlegroups.com.


Re: libatscc: packaging

2019-05-07 Thread artyom . shalkhakov
On Tuesday, May 7, 2019 at 5:58:44 AM UTC+3, M88 wrote:
>
>
> Somewhat related:  maybe it would be good to have some character-sequence 
> that represents a module accessor in the host language?
>
>
Yes, it makes sense to support some form of qualified identifiers in the 
source language. As it stands now, the ATS compiler will escape all "." and 
other symbols, so they would have to be unmangled.
 

> For example, something like "mac#Math**sqrt" could be translated to 
> "Math.sqrt" by atscc2[x], depending on what the module system uses for 
> namespaces.
>
> From an implementation standpoint, the accessor notatiion might be a rather* 
> bad* idea ( we'd be converting functions named "Math_052__052_sqrt" to 
> "Math.sqrt" ).  Still, maybe there
> are ways to make it better.
>
> Beyond making FFI easier, we'd also be able to package the prelude as a 
> module in the host language, which may have benefits (integration, 
> bundling, tree-shaking, etc) over
> methods like concatenation.  
>
>
Yes, this is precisely what I was aiming at, and note that the existing 
translators do this (except for atscc2js, which I planned to enhance with 
some support for ES modules). Not only do we want to package the prelude, 
but also the code that we get via the source-to-source compilers.
 

> Just a thought
>
> A while ago, I had attempted to add [es6, commonjs, IIFE, UMD] module 
> support to atscc2js.  Though it worked with a single file, I decided it had 
> little benefit over inline code blocks if there is no [easy] way to access 
> functions from the generated modules. 
>
>
Could you post this work somewhere? I'd like to have a look.
 

>
> On Monday, April 1, 2019 at 6:46:44 AM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hi all,
>>
>> I've started work on improving atscc2js yesterday and found that we have 
>> three similar projects:
>>
>>1. https://github.com/steinwaywhw/ATS-Python3
>>2. https://github.com/bakpakin/ats-lua
>>3. https://github.com/sazl/ats-go
>>4. and the in-progress atscc2js
>>
>> Every target programming language comes with its own "prelude" (e.g. 
>> libatscc2js for JS), but such preludes essentially implement the interfaces 
>> defined in libatscc.
>>
>> Now I'm thinking that we need to package up the interface and keep it as 
>> uniform as possible across the different targets, so that programmers may 
>> hopefully share more code between platforms with little issues (or no issue 
>> at all).
>>
>> With the above in mind, I propose to:
>>
>>1. package up libatscc somehow, e.g. put it on NPM (I'm working on 
>>this, it will require only minimal changes to the existing code)
>>2. come up with some process to maintain this 'specification' (maybe 
>>create a github organization and put this library into a repository; let 
>>people use issues and PRs to propose changes)
>>
>> Is anybody interested? If not I'll just go with the first point, and the 
>> specification will live on in the ATS-Postiats repository (for now).
>>
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/794604f3-e731-4080-bb54-e00bc5e16362%40googlegroups.com.


Re: Effectless ffi

2019-05-07 Thread artyom . shalkhakov
On Monday, May 6, 2019 at 10:21:40 AM UTC+3, Richard wrote:
>
> Oops, did not see you responded Artyom!
>

Richard you're very welcome to put your own suggestions! Better to 
reiterate twice than none at all. :-)

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/b152cfbe-2822-41fb-bbed-d17e75e82858%40googlegroups.com.


Re: Effectless ffi

2019-05-06 Thread Artyom Shalkhakov
Hi Alexander,

пн, 6 мая 2019 г. в 07:16, Dambaev Alexander :

> We can define external call as effectless (as I understand, this means
> "pure" in terns of ATS2);
>
> extern fn sqrt( double) :<> double = "ext#"
> extern fn launch_missles( double) :<> double = "ext#"
>
>
> I do understand, that this is due to goal to make transition from C to ATS
> to be less painful, but maybe, there should be some flag (like -XSafe for
> ghc, or maybe -Wall -Werror), which will treat effectless ffi calls to be
> compile time errors?
>
>
Effect annotations are used in ATS for a different reason (compared to
Haskell). Please see HX explaining it here:

https://groups.google.com/d/msg/ats-lang-users/L38Bzie5lsE/OnI1BXq8HoIJ


> And one more generic question: I haven't got if user can introduce new
> custom effects or are they just a predefined set of effects? Are there any
> docs about such topics in ATS?
>

We have some docs in the wiki, please see:

https://github.com/githwxi/ATS-Postiats/wiki/effects

-- 
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/c440ad8c-9322-44ca-ba6e-c3aaeabe0ece%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/c440ad8c-9322-44ca-ba6e-c3aaeabe0ece%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqhipLEPSW4YoW566RVQN4AwxTZJN45cx8hwpcFB61Foqg%40mail.gmail.com.


Re: Setting up ATS-Contrib

2019-04-04 Thread Artyom Shalkhakov
 I've also found it experimentally that atslib needs to be built in the 
correct environment (and probably prelude as well). That is to say, build 
the libats and prelude in a "MSYS2 MinGW 64-bit shell".

Assuming that your working dir is $PATSHOME:

$ make -C ccomp/atslib -f Makefile clean
$ make -C ccomp/atslib -f Makefile all

Then the samples in doc/EXAMPLE/ATSLIB mostly work too. For now I'm just 
excluding the POSIX-specific functionality.

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/d2f41790-9a41-4b5a-a9d7-d0420ab3d4f0%40googlegroups.com.


Re: Setting up ATS-Contrib

2019-04-03 Thread Artyom Shalkhakov
Hi Matt!

On Wednesday, April 3, 2019 at 9:59:39 AM UTC+3, Matt Chelen wrote:
>
> I'd definitely be interested in such a project, but I don't know that I 
> have the requisite knowledge to actually be of any help. I could certainly 
> try (I've always been a "learn as you go" sort of person), but I feel fair 
> warning that I may not be able to do much is in order.
>
>
Well it seems to me that this project is actually not as difficult as I 
thought!

I managed to compile some test programs and they run natively on Windows:


Now, the setup is of course quite difficult. Here's what I did:


   1. install MSYS2 and setup a development environment 
   <https://github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2>
   2. compile 
   <https://gist.github.com/ashalkhakov/4d9cc1a5fff9f9171f00a9ba50a24ebd>both 
   ATS1 and ATS2 from sources under MSYS2
   3. in MSYS2 shell, install via pacman the mingw-w64-x86_64-toolchain 
   <https://www.davidegrayson.com/windev/msys2/> (just hit ENTER to install 
   all tools) -- of course I assume you run an x86_64 system
   4. try to compile a very simple program, but now with this toolchain.. 
   how?

Basically the idea is that, to build a windows native app, you open the 
"MSYS2 MinGW 64-bit" shell (it's added to your Start Menu so it's easy to 
find).

To build an MSYS2 (aka non-native) app, you open the "MSYS2" shell. and 
then after opening the shell you just run "./configure&& install" 
as usual.

So, taking the example of arrinit.dats in $PATSHOME/doc/EXAMPLE/TESTATS, 
let us see what we can do.

The generated C file contains the prelude block (which just 
indiscriminately #includes all sorts of headers). We could also make our 
own user prelude tailored to Windows, I think.

Some notes:

   - the extensive symbolic linking that is used in ATS2 source repo is 
   horribly broken in MSYS2 (see the note in my gist; basically, instead of 
   symlinking, just copy the files over to their targets...)
  - oh, and I used git from MSYS2 to clone the ATS2/ATS2-contrib repos 
  when following my own script, maybe that is why the symlinks got broken.
  - the whole ATS2 toolchain still works in MSYS2, which is a kind of 
   Cygwin (meaning that all the binaries depend on msys dll) -- and we need a 
   better solution for general building... or perhaps, just leave it at that
   - I created a branch <https://www.davidegrayson.com/windev/msys2/> that 
   contains some fixes to ATS2 prelude to make this compilation possible -- 
   the upside is that fixing is VERY minimal! it will get worse as we come to 
   various system-provides functions, but shouldn't be too bad, I think.
   
On Wed, Apr 3, 2019 at 2:33 AM Artyom Shalkhakov  > wrote:
>
>> On Tuesday, April 2, 2019 at 2:46:06 PM UTC+3, Matt Chelen wrote:
>>>
>>> Yeah, I had intended on creating some graphical apps. Or, at the very 
>>> least, I like that option to be open to me. I'd also like to be able to 
>>> stay on Windows, ideally, as that's where the rest of my development 
>>> environment is at the moment.
>>>
>>>
>> Matt, I'm sorry about that. The current Windows support is only through 
>> Cygwin. The C generated by patsopt is very minimal though, so it should be 
>> possible to provide at least a prelude so as to make the code portable to 
>> MinGW64. Last time I tried this I had some issues with the (a) 
>> setjmp/longjmp (used for exception handling), (b) some file I/O primitives 
>> in [filebas], (c) forking in patscc (since I was a bit too ambitious I 
>> wanted to port the whole compiler, not just the compiled programs -- now, 
>> patscc can be re-implemented instead in a bash script that would run under 
>> MSYS2 shell).
>>
>> One other thing that might be problematic in such a port is that of build 
>> system: ATS1 and ATS2 by default use the "make" utility, so of course we'd 
>> need MSYS2 at the very least to make the build process portable (or we'd 
>> have to support some other alternative build system, such as SCons, -- it 
>> has been tried, it works, but it hasn't gained traction).
>>
>> Please ping me if you're interested. Maybe we can work something out 
>> (especially that ATS3 is in the works, and we'll of course carry over the 
>> experience gained in this project).
>>  
>>
>>> On Tue, Apr 2, 2019 at 7:33 AM Artyom Shalkhakov  
>>> wrote:
>>>
>>>> вт, 2 апр. 2019 г. в 14:27, Matt Chelen :
>>>>
>>>>> Alright, to test it out, I tried building Lazy Foo's fourth SDL 
>>>>> tutorial. It does not work, though that may be in part due to the fact 
>>>>> that 
>>>>> 

Re: Setting up ATS-Contrib

2019-04-03 Thread Artyom Shalkhakov
On Tuesday, April 2, 2019 at 2:46:06 PM UTC+3, Matt Chelen wrote:
>
> Yeah, I had intended on creating some graphical apps. Or, at the very 
> least, I like that option to be open to me. I'd also like to be able to 
> stay on Windows, ideally, as that's where the rest of my development 
> environment is at the moment.
>
>
Matt, I'm sorry about that. The current Windows support is only through 
Cygwin. The C generated by patsopt is very minimal though, so it should be 
possible to provide at least a prelude so as to make the code portable to 
MinGW64. Last time I tried this I had some issues with the (a) 
setjmp/longjmp (used for exception handling), (b) some file I/O primitives 
in [filebas], (c) forking in patscc (since I was a bit too ambitious I 
wanted to port the whole compiler, not just the compiled programs -- now, 
patscc can be re-implemented instead in a bash script that would run under 
MSYS2 shell).

One other thing that might be problematic in such a port is that of build 
system: ATS1 and ATS2 by default use the "make" utility, so of course we'd 
need MSYS2 at the very least to make the build process portable (or we'd 
have to support some other alternative build system, such as SCons, -- it 
has been tried, it works, but it hasn't gained traction).

Please ping me if you're interested. Maybe we can work something out 
(especially that ATS3 is in the works, and we'll of course carry over the 
experience gained in this project).
 

> On Tue, Apr 2, 2019 at 7:33 AM Artyom Shalkhakov  > wrote:
>
>> вт, 2 апр. 2019 г. в 14:27, Matt Chelen 
>> >:
>>
>>> Alright, to test it out, I tried building Lazy Foo's fourth SDL 
>>> tutorial. It does not work, though that may be in part due to the fact that 
>>> Cygwin applications apparently expect that an X11 server will be available. 
>>> So I tested it in MSYS2's MinGW64 shell with the same compilation flags 
>>> (adjusted for differences in library locations); it works.
>>>
>>>
>> Interesting.
>>  
>>>
>>> Furthermore, I've discovered that, according to the SDL installation 
>>> page ( https://wiki.libsdl.org/Installation ), Cygwin is no longer 
>>> supported. Even if it did work, the reliance on an X11 server is fairly 
>>> frustrating. Disappointing results overall. I'll have to see how I want to 
>>> proceed. Ultimately, it would be nice if it compiled in MSYS2's MinGW64 
>>> shell, but alas.
>>>
>>>
>> Yes, under Cygwin the programs would have to rely in X11 anyways. I used 
>> such apps in the past, they are slow but they work (e.g. Emacs works).
>>
>> Compiling ATS2 programs in MinGW64 should be doable, but there are some 
>> parts of the prelude that depend on POSIX interfaces (the compiler itself 
>> could be just as useful as Cygwinized application; at least in the short 
>> term). Do you intend to do some graphics apps using ATS? I'd suggest 
>> switching to Linux or MacOS for now, if you can.
>>  
>>
>>> On Tue, Apr 2, 2019 at 7:00 AM Artyom Shalkhakov >> > wrote:
>>>
>>>> вт, 2 апр. 2019 г. в 13:08, Matt Chelen >>> >:
>>>>
>>>>> SDL2 does work in Cygwin. It even has its own environment-specific SDL 
>>>>> DLL. Additionally, I tried running it outside of Cygwin, using the 
>>>>> required 
>>>>> DLLs, and it failed on startup.
>>>>>
>>>>> I added the -I flag to test02 in the makefile and it is also erroring 
>>>>> on the first use of assertloc.
>>>>>
>>>>> However, test00 returns the SDL version as expected.
>>>>>
>>>>> According to GitHub, the SDL2 wrapper hasn't been updated in five 
>>>>> years. Is it possible that it (or the examples) just doesn't work 
>>>>> properly 
>>>>> anymore?
>>>>>
>>>>>
>>>> Well, it compiles to C. So I guess that if you can run a toy C program 
>>>> that initializes SDL2 video subsystem properly on Windows with Cygwin, 
>>>> then 
>>>> the corresponding ATS program should work just the same. Could you try 
>>>> that 
>>>> as well?
>>>>  
>>>>
>>>>> Simply to test if there was something weird going on with assertloc, I 
>>>>> tested this example ( 
>>>>> https://github.com/githwxi/ATS-Postiats/blob/6539444fe641f7fa493140bd9940e5acf00960e3/doc/EXAMPLE/INTRO/f91.dats
>>>>>  
>>>>> ) and it works fine.
>>>>>
>>>>> If I set SDL_GetError() to a va

Re: Setting up ATS-Contrib

2019-04-02 Thread Artyom Shalkhakov
вт, 2 апр. 2019 г. в 13:08, Matt Chelen :

> SDL2 does work in Cygwin. It even has its own environment-specific SDL
> DLL. Additionally, I tried running it outside of Cygwin, using the required
> DLLs, and it failed on startup.
>
> I added the -I flag to test02 in the makefile and it is also erroring on
> the first use of assertloc.
>
> However, test00 returns the SDL version as expected.
>
> According to GitHub, the SDL2 wrapper hasn't been updated in five years.
> Is it possible that it (or the examples) just doesn't work properly anymore?
>
>
Well, it compiles to C. So I guess that if you can run a toy C program that
initializes SDL2 video subsystem properly on Windows with Cygwin, then the
corresponding ATS program should work just the same. Could you try that as
well?


> Simply to test if there was something weird going on with assertloc, I
> tested this example (
> https://github.com/githwxi/ATS-Postiats/blob/6539444fe641f7fa493140bd9940e5acf00960e3/doc/EXAMPLE/INTRO/f91.dats
> ) and it works fine.
>
> If I set SDL_GetError() to a variable, it goes past it and errors at the
> first assertloc. If I try to print it directly, it won't let me;
> compilation fails. SDL_Log is unrecognized. I've yet to go through any of
> the ATS tutorial material (I was just trying to get all of this set up and
> working), so I'm unsure how to proceed.
>
> On Tue, Apr 2, 2019 at 5:08 AM Artyom Shalkhakov <
> artyom.shalkha...@gmail.com> wrote:
>
>> вт, 2 апр. 2019 г. в 12:02, Matt Chelen :
>>
>>> $ pkg-config sdl2 --cflags
>>>> -I/usr/include/SDL2 -D_REENTRANT
>>>>
>>>
>>> As a side-note, I passed the $PATSCONTRIB -I flag to the make command
>>> and it built test00 and test01, but test02 failed and test01 will not run,
>>> instead throwing an error on the first use of assertloc.
>>>
>>> /usr/local/lib/ats2-postiats-0.3.13/contrib/SDL2/test/test01.dats:
>>>> 311(line=25, offs=18) -- 331(line=25, offs=38)
>>>>
>>>
>>>
>> You use Windows and Cygwin, right? I'm wondering if SDL2 even works in
>> this setting? The assertion has to do with SDL_Init returning an error
>> code. Could you add a call to SDL_GetError() somewhere in there? As shown
>> here, basically:
>>
>> https://wiki.libsdl.org/SDL_Init
>>
>>
>>> test02 throws the same error as I had originally due to having different
>>> cflags, so I think I am going to have to edit the makefile to get it to
>>> recognize the added -I flag.
>>>
>>> On Tue, Apr 2, 2019 at 4:57 AM Artyom Shalkhakov <
>>> artyom.shalkha...@gmail.com> wrote:
>>>
>>>> Matt,
>>>>
>>>> Indeed it's quite puzzling to me as well.
>>>>
>>>> вт, 2 апр. 2019 г. в 11:33, Matt Chelen :
>>>>
>>>>> Manually including the contrib folder with a -I flag seems to have
>>>>> worked (other than the SDL_GetVersion function causing an undefined
>>>>> reference error), but I'm still confused as to why it didn't just work. 
>>>>> The
>>>>> documentation basically states that the way I had it set up is a valid way
>>>>> to set up the contrib folder, whereas having to manually include the
>>>>> contrib folder says the opposite.
>>>>>
>>>>>
>>>> Could you tell me what the following command evaluates to in your
>>>> terminal:
>>>>
>>>> $ pkg-config sdl2 --cflags
>>>>
>>>> I picked it up from here:
>>>>
>>>>
>>>> https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/SDL2/TEST/Makefile
>>>>
>>>> Notice that in this makefile, CFLAGS are added to the C compiler so
>>>> that it can find SDL2. Maybe the makefile should also add an -I>>> of contrib/>.
>>>>
>>>> On Tue, Apr 2, 2019 at 4:23 AM Artyom Shalkhakov <
>>>>> artyom.shalkha...@gmail.com> wrote:
>>>>>
>>>>>> вт, 2 апр. 2019 г. в 11:19, Matt Chelen :
>>>>>>
>>>>>>> I just realized now that the file referenced in the comment is the
>>>>>>> SATS file and that I had misread it, but it should hold that, if it can
>>>>>>> find the SATS file, which is simply in a different subdirectory of
>>>>>>> contrib/SDL2, it should be able to find the CATS file, unless I am 
>>>>>>> mistaken
>>>>>>> about how this is supposed to be set up.
>

Re: Setting up ATS-Contrib

2019-04-02 Thread Artyom Shalkhakov
вт, 2 апр. 2019 г. в 12:02, Matt Chelen :

> $ pkg-config sdl2 --cflags
>> -I/usr/include/SDL2 -D_REENTRANT
>>
>
> As a side-note, I passed the $PATSCONTRIB -I flag to the make command and
> it built test00 and test01, but test02 failed and test01 will not run,
> instead throwing an error on the first use of assertloc.
>
> /usr/local/lib/ats2-postiats-0.3.13/contrib/SDL2/test/test01.dats:
>> 311(line=25, offs=18) -- 331(line=25, offs=38)
>>
>
>
You use Windows and Cygwin, right? I'm wondering if SDL2 even works in this
setting? The assertion has to do with SDL_Init returning an error code.
Could you add a call to SDL_GetError() somewhere in there? As shown here,
basically:

https://wiki.libsdl.org/SDL_Init


> test02 throws the same error as I had originally due to having different
> cflags, so I think I am going to have to edit the makefile to get it to
> recognize the added -I flag.
>
> On Tue, Apr 2, 2019 at 4:57 AM Artyom Shalkhakov <
> artyom.shalkha...@gmail.com> wrote:
>
>> Matt,
>>
>> Indeed it's quite puzzling to me as well.
>>
>> вт, 2 апр. 2019 г. в 11:33, Matt Chelen :
>>
>>> Manually including the contrib folder with a -I flag seems to have
>>> worked (other than the SDL_GetVersion function causing an undefined
>>> reference error), but I'm still confused as to why it didn't just work. The
>>> documentation basically states that the way I had it set up is a valid way
>>> to set up the contrib folder, whereas having to manually include the
>>> contrib folder says the opposite.
>>>
>>>
>> Could you tell me what the following command evaluates to in your
>> terminal:
>>
>> $ pkg-config sdl2 --cflags
>>
>> I picked it up from here:
>>
>>
>> https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/SDL2/TEST/Makefile
>>
>> Notice that in this makefile, CFLAGS are added to the C compiler so that
>> it can find SDL2. Maybe the makefile should also add an -I> contrib/>.
>>
>> On Tue, Apr 2, 2019 at 4:23 AM Artyom Shalkhakov <
>>> artyom.shalkha...@gmail.com> wrote:
>>>
>>>> вт, 2 апр. 2019 г. в 11:19, Matt Chelen :
>>>>
>>>>> I just realized now that the file referenced in the comment is the
>>>>> SATS file and that I had misread it, but it should hold that, if it can
>>>>> find the SATS file, which is simply in a different subdirectory of
>>>>> contrib/SDL2, it should be able to find the CATS file, unless I am 
>>>>> mistaken
>>>>> about how this is supposed to be set up.
>>>>>
>>>>>
>>>> Well, the #includes in .cats files are resolved by the underlying C
>>>> compiler, hence I think the issue is somehow in the C compiler (maybe it
>>>> needs another -I flag or some such?)
>>>>
>>>>
>>>>> On Tue, Apr 2, 2019 at 4:13 AM Matt Chelen 
>>>>> wrote:
>>>>>
>>>>>> My contrib folder is in $PATSHOME/contrib. I've tried setting both
>>>>>> the $PATSCONTRIB environment variable to both $PATSHOME, which I think 
>>>>>> the
>>>>>> documentation said to do (it is entirely possible that I misunderstood 
>>>>>> the
>>>>>> phrasing), and $PATSHOME/contrib, both with the same result.
>>>>>>
>>>>>> The SDL2 folder is in the contrib folder. It's just cloned from the
>>>>>> GitHub repo and copied in there. The examples that I'm trying to build 
>>>>>> are
>>>>>> in $PATSHOME/contrib/SDL2/TEST and the actual bindings are in
>>>>>> $PATSHOME/contrib/SDL2/CATS/SDL.cats.
>>>>>>
>>>>>> Here's the relevant part of the generated C file, showing that it has
>>>>>> the correct path to the file in question in the comment.
>>>>>>
>>>>>> /*
>>>>>> /usr/local/lib/ats2-postiats-0.3.13/contrib/SDL2/SATS/SDL.sats:
>>>>>> 899(line=29, offs=1) -- 941(line=33, offs=3)
>>>>>> */
>>>>>>
>>>>>> //
>>>>>> #include "SDL2/CATS/SDL.cats"
>>>>>>
>>>>>> What it looks like (to me) is that it's just not resolving properly.
>>>>>> None of the prelude ATS files that are included before that point are
>>>>>> throwing errors. Just that one. Manually changing the location to
>>>>>> "con

Re: Setting up ATS-Contrib

2019-04-02 Thread Artyom Shalkhakov
Matt,

Indeed it's quite puzzling to me as well.

вт, 2 апр. 2019 г. в 11:33, Matt Chelen :

> Manually including the contrib folder with a -I flag seems to have worked
> (other than the SDL_GetVersion function causing an undefined reference
> error), but I'm still confused as to why it didn't just work. The
> documentation basically states that the way I had it set up is a valid way
> to set up the contrib folder, whereas having to manually include the
> contrib folder says the opposite.
>
>
Could you tell me what the following command evaluates to in your terminal:

$ pkg-config sdl2 --cflags

I picked it up from here:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/SDL2/TEST/Makefile

Notice that in this makefile, CFLAGS are added to the C compiler so that it
can find SDL2. Maybe the makefile should also add an -I.

On Tue, Apr 2, 2019 at 4:23 AM Artyom Shalkhakov <
> artyom.shalkha...@gmail.com> wrote:
>
>> вт, 2 апр. 2019 г. в 11:19, Matt Chelen :
>>
>>> I just realized now that the file referenced in the comment is the SATS
>>> file and that I had misread it, but it should hold that, if it can find the
>>> SATS file, which is simply in a different subdirectory of contrib/SDL2, it
>>> should be able to find the CATS file, unless I am mistaken about how this
>>> is supposed to be set up.
>>>
>>>
>> Well, the #includes in .cats files are resolved by the underlying C
>> compiler, hence I think the issue is somehow in the C compiler (maybe it
>> needs another -I flag or some such?)
>>
>>
>>> On Tue, Apr 2, 2019 at 4:13 AM Matt Chelen  wrote:
>>>
>>>> My contrib folder is in $PATSHOME/contrib. I've tried setting both the
>>>> $PATSCONTRIB environment variable to both $PATSHOME, which I think the
>>>> documentation said to do (it is entirely possible that I misunderstood the
>>>> phrasing), and $PATSHOME/contrib, both with the same result.
>>>>
>>>> The SDL2 folder is in the contrib folder. It's just cloned from the
>>>> GitHub repo and copied in there. The examples that I'm trying to build are
>>>> in $PATSHOME/contrib/SDL2/TEST and the actual bindings are in
>>>> $PATSHOME/contrib/SDL2/CATS/SDL.cats.
>>>>
>>>> Here's the relevant part of the generated C file, showing that it has
>>>> the correct path to the file in question in the comment.
>>>>
>>>> /*
>>>> /usr/local/lib/ats2-postiats-0.3.13/contrib/SDL2/SATS/SDL.sats:
>>>> 899(line=29, offs=1) -- 941(line=33, offs=3)
>>>> */
>>>>
>>>> //
>>>> #include "SDL2/CATS/SDL.cats"
>>>>
>>>> What it looks like (to me) is that it's just not resolving properly.
>>>> None of the prelude ATS files that are included before that point are
>>>> throwing errors. Just that one. Manually changing the location to
>>>> "contrib/SDL2/CATS/SDL.cats" allows patscc to get past the error, but I
>>>> then run into similar errors with the files that it includes. I'm just not
>>>> sure why it's not resolving properly. Adding contrib to the beginning is
>>>> required to get it to resolve even if I set $PATSCONTRIB to
>>>> $PATSHOME/contrib.
>>>>
>>>> Do you think it might work properly if I move $PATSCONTRIB somewhere
>>>> else or is something else going on?
>>>>
>>>> On Tuesday, April 2, 2019 at 3:07:05 AM UTC-4, Artyom Shalkhakov wrote:
>>>>>
>>>>> Hi Matt,
>>>>>
>>>>> On Monday, April 1, 2019 at 6:53:00 PM UTC+3, Matt Chelen wrote:
>>>>>>
>>>>>> I'm trying to get ATS-Contrib set up and I'm concerned that I don't
>>>>>> currently have it configured correctly. As per the documentation, I put 
>>>>>> the
>>>>>> "contrib" folder in $PATSHOME and set $PATSCONTRIB to $PATSHOME.
>>>>>>
>>>>>> The issue is that I tried compiling the SDL sample programs and,
>>>>>> while the ATS compiler compiles them just fine, I get errors like the
>>>>>> following from the resulting C source.
>>>>>>
>>>>>> $ make
>>>>>> "/usr/local/lib/ats2-postiats-0.3.13"/bin/patscc -I
>>>>>> "/usr/local/lib/ats2-postiats-0.3.13" -I
>>>>>> "/usr/local/lib/ats2-postiats-0.3.13"/ccomp/runtime  -D_GNU_SOURCE -I
>>>>>> /usr/include/SDL2 -D_REENTRANT  -o test

Re: Setting up ATS-Contrib

2019-04-02 Thread Artyom Shalkhakov
вт, 2 апр. 2019 г. в 11:19, Matt Chelen :

> I just realized now that the file referenced in the comment is the SATS
> file and that I had misread it, but it should hold that, if it can find the
> SATS file, which is simply in a different subdirectory of contrib/SDL2, it
> should be able to find the CATS file, unless I am mistaken about how this
> is supposed to be set up.
>
>
Well, the #includes in .cats files are resolved by the underlying C
compiler, hence I think the issue is somehow in the C compiler (maybe it
needs another -I flag or some such?)


> On Tue, Apr 2, 2019 at 4:13 AM Matt Chelen  wrote:
>
>> My contrib folder is in $PATSHOME/contrib. I've tried setting both the
>> $PATSCONTRIB environment variable to both $PATSHOME, which I think the
>> documentation said to do (it is entirely possible that I misunderstood the
>> phrasing), and $PATSHOME/contrib, both with the same result.
>>
>> The SDL2 folder is in the contrib folder. It's just cloned from the
>> GitHub repo and copied in there. The examples that I'm trying to build are
>> in $PATSHOME/contrib/SDL2/TEST and the actual bindings are in
>> $PATSHOME/contrib/SDL2/CATS/SDL.cats.
>>
>> Here's the relevant part of the generated C file, showing that it has the
>> correct path to the file in question in the comment.
>>
>> /*
>> /usr/local/lib/ats2-postiats-0.3.13/contrib/SDL2/SATS/SDL.sats:
>> 899(line=29, offs=1) -- 941(line=33, offs=3)
>> */
>>
>> //
>> #include "SDL2/CATS/SDL.cats"
>>
>> What it looks like (to me) is that it's just not resolving properly. None
>> of the prelude ATS files that are included before that point are throwing
>> errors. Just that one. Manually changing the location to
>> "contrib/SDL2/CATS/SDL.cats" allows patscc to get past the error, but I
>> then run into similar errors with the files that it includes. I'm just not
>> sure why it's not resolving properly. Adding contrib to the beginning is
>> required to get it to resolve even if I set $PATSCONTRIB to
>> $PATSHOME/contrib.
>>
>> Do you think it might work properly if I move $PATSCONTRIB somewhere else
>> or is something else going on?
>>
>> On Tuesday, April 2, 2019 at 3:07:05 AM UTC-4, Artyom Shalkhakov wrote:
>>>
>>> Hi Matt,
>>>
>>> On Monday, April 1, 2019 at 6:53:00 PM UTC+3, Matt Chelen wrote:
>>>>
>>>> I'm trying to get ATS-Contrib set up and I'm concerned that I don't
>>>> currently have it configured correctly. As per the documentation, I put the
>>>> "contrib" folder in $PATSHOME and set $PATSCONTRIB to $PATSHOME.
>>>>
>>>> The issue is that I tried compiling the SDL sample programs and, while
>>>> the ATS compiler compiles them just fine, I get errors like the following
>>>> from the resulting C source.
>>>>
>>>> $ make
>>>> "/usr/local/lib/ats2-postiats-0.3.13"/bin/patscc -I
>>>> "/usr/local/lib/ats2-postiats-0.3.13" -I
>>>> "/usr/local/lib/ats2-postiats-0.3.13"/ccomp/runtime  -D_GNU_SOURCE -I/
>>>> usr/include/SDL2 -D_REENTRANT  -o test00 test00.dats -L
>>>> "/usr/local/lib/ats2-postiats-0.3.13"/ccomp/atslib/lib -latslib -lSDL2
>>>> test00_dats.c:82:10: fatal error: SDL2/CATS/SDL.cats: No such file or
>>>> directory
>>>>  #include "SDL2/CATS/SDL.cats"
>>>>   ^~~~
>>>> compilation terminated.
>>>> make: *** [Makefile:41: test00] Error 1
>>>>
>>>> The same thing happens if I set $PATSCONTRIB to $PATSHOME/contrib. Did
>>>> I set something up incorrectly? Is this a problem with the library? Is this
>>>> a Cygwin issue?
>>>>
>>>
>>> Could you check what is in those -I directories? In particular, where
>>> are the SDL2/CATS/SDL.cats files located, and what is your $PATSCONTRIB,
>>> does it have an SDL2 subdirectory?
>>>
>>>
>>>> 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-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to ats-lang-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ats-lang-users/be4dd68f-8

Re: Setting up ATS-Contrib

2019-04-02 Thread Artyom Shalkhakov
Hi Matt,

On Monday, April 1, 2019 at 6:53:00 PM UTC+3, Matt Chelen wrote:
>
> I'm trying to get ATS-Contrib set up and I'm concerned that I don't 
> currently have it configured correctly. As per the documentation, I put the 
> "contrib" folder in $PATSHOME and set $PATSCONTRIB to $PATSHOME.
>
> The issue is that I tried compiling the SDL sample programs and, while the 
> ATS compiler compiles them just fine, I get errors like the following from 
> the resulting C source.
>
> $ make
> "/usr/local/lib/ats2-postiats-0.3.13"/bin/patscc -I
> "/usr/local/lib/ats2-postiats-0.3.13" -I
> "/usr/local/lib/ats2-postiats-0.3.13"/ccomp/runtime  -D_GNU_SOURCE -I/usr/
> include/SDL2 -D_REENTRANT  -o test00 test00.dats -L
> "/usr/local/lib/ats2-postiats-0.3.13"/ccomp/atslib/lib -latslib -lSDL2
> test00_dats.c:82:10: fatal error: SDL2/CATS/SDL.cats: No such file or 
> directory
>  #include "SDL2/CATS/SDL.cats"
>   ^~~~
> compilation terminated.
> make: *** [Makefile:41: test00] Error 1
>
> The same thing happens if I set $PATSCONTRIB to $PATSHOME/contrib. Did I 
> set something up incorrectly? Is this a problem with the library? Is this a 
> Cygwin issue?
>

Could you check what is in those -I directories? In particular, where are 
the SDL2/CATS/SDL.cats files located, and what is your $PATSCONTRIB, does 
it have an SDL2 subdirectory?
 

> 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-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/d0bf3b79-e8c8-4ae1-b690-6fe926fb5821%40googlegroups.com.


libatscc: packaging

2019-04-01 Thread Artyom Shalkhakov
Hi all,

I've started work on improving atscc2js yesterday and found that we have 
three similar projects:

   1. https://github.com/steinwaywhw/ATS-Python3
   2. https://github.com/bakpakin/ats-lua
   3. https://github.com/sazl/ats-go
   4. and the in-progress atscc2js
   
Every target programming language comes with its own "prelude" (e.g. 
libatscc2js for JS), but such preludes essentially implement the interfaces 
defined in libatscc.

Now I'm thinking that we need to package up the interface and keep it as 
uniform as possible across the different targets, so that programmers may 
hopefully share more code between platforms with little issues (or no issue 
at all).

With the above in mind, I propose to:

   1. package up libatscc somehow, e.g. put it on NPM (I'm working on this, 
   it will require only minimal changes to the existing code)
   2. come up with some process to maintain this 'specification' (maybe 
   create a github organization and put this library into a repository; let 
   people use issues and PRs to propose changes)
   
Is anybody interested? If not I'll just go with the first point, and the 
specification will live on in the ATS-Postiats repository (for now).

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/969970ce-8851-425f-84fb-93cd6414de34%40googlegroups.com.


Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
On Tuesday, March 26, 2019 at 5:14:34 PM UTC+2, gmhwxi wrote:
>
> Boxing is removed:
>
> https://pastebin.com/JacNgK2t
>
> Some hacks are used to make it work...
>
>
This is awesome. Now we don't need to allocate every time we call a 'read' 
function. :)

Thanks! I've updated my gist with this and a note.
 

>
>
> On Tue, Mar 26, 2019 at 10:14 AM Hongwei Xi  > wrote:
>
>> >>Did you mean to use vtype in {a,b:vtype} here? Or not?
>>
>> Typo: vtype should be vt@ype. 
>>
>> On Tue, Mar 26, 2019 at 10:12 AM Artyom Shalkhakov > > wrote:
>>
>>> On Tuesday, March 26, 2019 at 4:07:38 PM UTC+2, gmhwxi wrote:
>>>>
>>>> A "standard" solution is to use call-by-reference:
>>>>
>>>> extern
>>>> fun
>>>> runCommand
>>>> {a:vt@ype}
>>>> (c:Command(a:vt@ype), ? >> a): void
>>>>
>>>>
>>> I think we covered this a few months back when Chris asked about it. 
>>> This finally reminded me of that discussion.
>>>  
>>>
>>>> datavtype
>>>> Command(vt@ype) =
>>>>   | Nop(unit)
>>>>   | Read(string)
>>>>   | Print(unit) of string
>>>>   | Seq(unit) of (Command(unit), Command(unit))
>>>>   | {a,b:vtype} Bind(b) of (Command(a), a?, ( >> a?) - 
>>>> Command(b))
>>>>
>>>  
>>> Did you mean to use vtype in {a,b:vtype} here? Or not?
>>>  
>>>
>>>> This is a bit more involved but only an implementer like you (not user) 
>>>> needs to deal with it :)
>>>>
>>>
>>> Hmmm. A sane approach to dependent types is when the user needs none of 
>>> dependent types to get things going. :)
>>>  
>>>
>>>>  
>>>>
>>>
>>>> On Tue, Mar 26, 2019 at 10:01 AM Artyom Shalkhakov <
>>>> artyom.s...@gmail.com> wrote:
>>>>
>>>>> On Tuesday, March 26, 2019 at 3:55:47 PM UTC+2, gmhwxi wrote:
>>>>>>
>>>>>> >> Now, what about boxing, can we do something with boxing?
>>>>>>
>>>>>> Do you mean that you want to have 'a:t@ype' instead of 'a:type'?
>>>>>>
>>>>>>
>>>>> Yes. I think any use of 'bind' is highly discouraged if we have 
>>>>> 'a:type' restriction (e.g. want to return an int from an effectful 
>>>>> function 
>>>>> -- sure, but use heap for that...).
>>>>>  
>>>>>
>>>>>> On Tue, Mar 26, 2019 at 9:36 AM Artyom Shalkhakov <
>>>>>> artyom.s...@gmail.com> wrote:
>>>>>>
>>>>>>> Hi Hongwei,
>>>>>>>
>>>>>>> On Tuesday, March 26, 2019 at 3:22:41 PM UTC+2, gmhwxi wrote:
>>>>>>>>
>>>>>>>> Here is a linear version:
>>>>>>>>
>>>>>>>> https://pastebin.com/sqXcRhnf
>>>>>>>>
>>>>>>>> Also, Command is a linear datatype (i.e., dataviewtype).
>>>>>>>>
>>>>>>>>
>>>>>>> Great! Now, what about boxing, can we do something with boxing? I 
>>>>>>> expect such code, if it's really used in practice, to involve LOTS of 
>>>>>>> these 
>>>>>>> little objects. So it will probably behave badly if every call to a 
>>>>>>> continuation involves a heap allocation... Let us be a bit more 
>>>>>>> resource-conscious, please. :)
>>>>>>>
>>>>>>> I did a similar example a while back where I used some CPS style to 
>>>>>>> get rid of boxing:
>>>>>>>
>>>>>>> https://github.com/ashalkhakov/tfc/blob/master/src/SATS/cont.sats
>>>>>>>
>>>>>>> Basically we can 'co-opt' the ATS compiler to do all the plumbing. 
>>>>>>> The closure call and its packing is non-uniform but the closure itself 
>>>>>>> is 
>>>>>>> uniform in size, since it's a pointer to the heap:
>>>>>>>
>>>>>>> https://github.com/ashalkhakov/tfc/blob/master/test/threads.dats
>>>>>>>
>>>>>>> To call a continuation, the return type must be statically known (at 
>>>>>>> both the callee side and the caller side).
>>

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
On Tuesday, March 26, 2019 at 4:07:38 PM UTC+2, gmhwxi wrote:
>
> A "standard" solution is to use call-by-reference:
>
> extern
> fun
> runCommand
> {a:vt@ype}
> (c:Command(a:vt@ype), ? >> a): void
>
>
I think we covered this a few months back when Chris asked about it. This 
finally reminded me of that discussion.
 

> datavtype
> Command(vt@ype) =
>   | Nop(unit)
>   | Read(string)
>   | Print(unit) of string
>   | Seq(unit) of (Command(unit), Command(unit))
>   | {a,b:vtype} Bind(b) of (Command(a), a?, ( >> a?) - 
> Command(b))
>
 
Did you mean to use vtype in {a,b:vtype} here? Or not?
 

> This is a bit more involved but only an implementer like you (not user) 
> needs to deal with it :)
>

Hmmm. A sane approach to dependent types is when the user needs none of 
dependent types to get things going. :)
 

>  
>

> On Tue, Mar 26, 2019 at 10:01 AM Artyom Shalkhakov  > wrote:
>
>> On Tuesday, March 26, 2019 at 3:55:47 PM UTC+2, gmhwxi wrote:
>>>
>>> >> Now, what about boxing, can we do something with boxing?
>>>
>>> Do you mean that you want to have 'a:t@ype' instead of 'a:type'?
>>>
>>>
>> Yes. I think any use of 'bind' is highly discouraged if we have 'a:type' 
>> restriction (e.g. want to return an int from an effectful function -- sure, 
>> but use heap for that...).
>>  
>>
>>> On Tue, Mar 26, 2019 at 9:36 AM Artyom Shalkhakov  
>>> wrote:
>>>
>>>> Hi Hongwei,
>>>>
>>>> On Tuesday, March 26, 2019 at 3:22:41 PM UTC+2, gmhwxi wrote:
>>>>>
>>>>> Here is a linear version:
>>>>>
>>>>> https://pastebin.com/sqXcRhnf
>>>>>
>>>>> Also, Command is a linear datatype (i.e., dataviewtype).
>>>>>
>>>>>
>>>> Great! Now, what about boxing, can we do something with boxing? I 
>>>> expect such code, if it's really used in practice, to involve LOTS of 
>>>> these 
>>>> little objects. So it will probably behave badly if every call to a 
>>>> continuation involves a heap allocation... Let us be a bit more 
>>>> resource-conscious, please. :)
>>>>
>>>> I did a similar example a while back where I used some CPS style to get 
>>>> rid of boxing:
>>>>
>>>> https://github.com/ashalkhakov/tfc/blob/master/src/SATS/cont.sats
>>>>
>>>> Basically we can 'co-opt' the ATS compiler to do all the plumbing. The 
>>>> closure call and its packing is non-uniform but the closure itself is 
>>>> uniform in size, since it's a pointer to the heap:
>>>>
>>>> https://github.com/ashalkhakov/tfc/blob/master/test/threads.dats
>>>>
>>>> To call a continuation, the return type must be statically known (at 
>>>> both the callee side and the caller side).
>>>>
>>>> So maybe we can do something similar here?
>>>>  
>>>>>
>>>>>
>>>>> On Tue, Mar 26, 2019 at 9:02 AM Hongwei Xi  wrote:
>>>>>
>>>>>> Nice!
>>>>>>
>>>>>> But I am very surprised that this code actually works.
>>>>>> My understanding is that It works because of a bug in patsopt :)
>>>>>>
>>>>>> Basically, runCommand should be implemented as a polymorphic function 
>>>>>> (instead of a function
>>>>>> template). And 'a:t0ype' should be 'a:type'.
>>>>>>
>>>>>> fun runCommand: {a:type} Command(a) -> a
>>>>>>
>>>>>> Actually, I think that Command should be a linear type, which should 
>>>>>> you more fun!
>>>>>>
>>>>>> On Tue, Mar 26, 2019 at 5:49 AM Artyom Shalkhakov <
>>>>>> artyom.s...@gmail.com> wrote:
>>>>>>
>>>>>>> I've made a gist:
>>>>>>>
>>>>>>> https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056
>>>>>>>
>>>>>>> It actually works. It illustrates the basics (sequencing, bind, 
>>>>>>> input and output). Nice. It doesn't have Haskell's "return" though, but 
>>>>>>> that is pretty simple to add (it's something that "creates" IO where 
>>>>>>> there 
>>>>>>> is no IO at all...).
>>>>>>>
>>>>>>> The interpreter

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
On Tuesday, March 26, 2019 at 3:55:47 PM UTC+2, gmhwxi wrote:
>
> >> Now, what about boxing, can we do something with boxing?
>
> Do you mean that you want to have 'a:t@ype' instead of 'a:type'?
>
>
Yes. I think any use of 'bind' is highly discouraged if we have 'a:type' 
restriction (e.g. want to return an int from an effectful function -- sure, 
but use heap for that...).
 

> On Tue, Mar 26, 2019 at 9:36 AM Artyom Shalkhakov  > wrote:
>
>> Hi Hongwei,
>>
>> On Tuesday, March 26, 2019 at 3:22:41 PM UTC+2, gmhwxi wrote:
>>>
>>> Here is a linear version:
>>>
>>> https://pastebin.com/sqXcRhnf
>>>
>>> Also, Command is a linear datatype (i.e., dataviewtype).
>>>
>>>
>> Great! Now, what about boxing, can we do something with boxing? I expect 
>> such code, if it's really used in practice, to involve LOTS of these little 
>> objects. So it will probably behave badly if every call to a continuation 
>> involves a heap allocation... Let us be a bit more resource-conscious, 
>> please. :)
>>
>> I did a similar example a while back where I used some CPS style to get 
>> rid of boxing:
>>
>> https://github.com/ashalkhakov/tfc/blob/master/src/SATS/cont.sats
>>
>> Basically we can 'co-opt' the ATS compiler to do all the plumbing. The 
>> closure call and its packing is non-uniform but the closure itself is 
>> uniform in size, since it's a pointer to the heap:
>>
>> https://github.com/ashalkhakov/tfc/blob/master/test/threads.dats
>>
>> To call a continuation, the return type must be statically known (at both 
>> the callee side and the caller side).
>>
>> So maybe we can do something similar here?
>>  
>>>
>>>
>>> On Tue, Mar 26, 2019 at 9:02 AM Hongwei Xi  wrote:
>>>
>>>> Nice!
>>>>
>>>> But I am very surprised that this code actually works.
>>>> My understanding is that It works because of a bug in patsopt :)
>>>>
>>>> Basically, runCommand should be implemented as a polymorphic function 
>>>> (instead of a function
>>>> template). And 'a:t0ype' should be 'a:type'.
>>>>
>>>> fun runCommand: {a:type} Command(a) -> a
>>>>
>>>> Actually, I think that Command should be a linear type, which should 
>>>> you more fun!
>>>>
>>>> On Tue, Mar 26, 2019 at 5:49 AM Artyom Shalkhakov <
>>>> artyom.s...@gmail.com> wrote:
>>>>
>>>>> I've made a gist:
>>>>>
>>>>> https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056
>>>>>
>>>>> It actually works. It illustrates the basics (sequencing, bind, input 
>>>>> and output). Nice. It doesn't have Haskell's "return" though, but that is 
>>>>> pretty simple to add (it's something that "creates" IO where there is no 
>>>>> IO 
>>>>> at all...).
>>>>>
>>>>> The interpreter is using a continuation in the end. I chose this style 
>>>>> because the closure-function (i.e. our continuation) can be passed around 
>>>>> freely, whereas with a flat unboxed type it is sometimes difficult for 
>>>>> the 
>>>>> C compiler to figure out the size of the variable.
>>>>>
>>>>> On Tuesday, March 26, 2019 at 10:11:11 AM UTC+2, Artyom Shalkhakov 
>>>>> wrote:
>>>>>
>>>>>> Hi Brandon,
>>>>>>
>>>>>> On Friday, March 22, 2019 at 8:49:29 PM UTC+2, Brandon Barker wrote:
>>>>>>>
>>>>>>> Hey Artyom,
>>>>>>>
>>>>>>> Thanks for the very interesting analysis and response.
>>>>>>>
>>>>>>>
>>>>>> Glad you found it useful!
>>>>>>
>>>>>> On Fri, Mar 22, 2019 at 4:06 AM Artyom Shalkhakov <
>>>>>>> artyom.s...@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi Brandon,
>>>>>>>>
>>>>>>>> This is a very lively discussion, thanks for bringing it up.
>>>>>>>>
>>>>>>>> On Friday, March 22, 2019 at 5:48:07 AM UTC+2, Brandon Barker wrote:
>>>>>>>>>
>>>>>>>>> And for what it's worth, here is an Idris program for haha using 
>>>>>>>>> Effects:
>>&

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
On Tuesday, March 26, 2019 at 3:02:42 PM UTC+2, gmhwxi wrote:
>
> Nice!
>
> But I am very surprised that this code actually works.
> My understanding is that It works because of a bug in patsopt :)
>
>
May I suggest this bug to be classified as a feature. :)

Basically, runCommand should be implemented as a polymorphic function 
> (instead of a function
> template). And 'a:t0ype' should be 'a:type'.
>
> fun runCommand: {a:type} Command(a) -> a
>
> Actually, I think that Command should be a linear type, which should you 
> more fun!
>
> On Tue, Mar 26, 2019 at 5:49 AM Artyom Shalkhakov  > wrote:
>
>> I've made a gist:
>>
>> https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056
>>
>> It actually works. It illustrates the basics (sequencing, bind, input and 
>> output). Nice. It doesn't have Haskell's "return" though, but that is 
>> pretty simple to add (it's something that "creates" IO where there is no IO 
>> at all...).
>>
>> The interpreter is using a continuation in the end. I chose this style 
>> because the closure-function (i.e. our continuation) can be passed around 
>> freely, whereas with a flat unboxed type it is sometimes difficult for the 
>> C compiler to figure out the size of the variable.
>>
>> On Tuesday, March 26, 2019 at 10:11:11 AM UTC+2, Artyom Shalkhakov wrote:
>>
>>> Hi Brandon,
>>>
>>> On Friday, March 22, 2019 at 8:49:29 PM UTC+2, Brandon Barker wrote:
>>>>
>>>> Hey Artyom,
>>>>
>>>> Thanks for the very interesting analysis and response.
>>>>
>>>>
>>> Glad you found it useful!
>>>
>>> On Fri, Mar 22, 2019 at 4:06 AM Artyom Shalkhakov  
>>>> wrote:
>>>>
>>>>> Hi Brandon,
>>>>>
>>>>> This is a very lively discussion, thanks for bringing it up.
>>>>>
>>>>> On Friday, March 22, 2019 at 5:48:07 AM UTC+2, Brandon Barker wrote:
>>>>>>
>>>>>> And for what it's worth, here is an Idris program for haha using 
>>>>>> Effects:
>>>>>>
>>>>>> module Main
>>>>>>
>>>>>>
>>>>>> import Effects
>>>>>> import Effect.StdIO
>>>>>>
>>>>>>
>>>>>> hello : Eff () [STDIO]
>>>>>> hello = let ha = StdIO.putStr "ha" in ha *> ha
>>>>>>
>>>>>>
>>>>>> main : IO ()
>>>>>> main = run hello
>>>>>>
>>>>>>
>>>>>>
>>>>>> It prints "ha" twice, despite being a strict language. I presume, but 
>>>>>> am not sure, this is because the effect time requires it to be 
>>>>>> re-evaluated 
>>>>>> each time.
>>>>>>
>>>>>>
>>>>>>
>>>>> Well, the type of "hello" says that the computation will use the STDIO 
>>>>> effect as many times as is necessary. The way the computation is 
>>>>> constructed, it is meant to issue commands in a given sequence.
>>>>>
>>>>> One peculiarity of PureScript is that of handling effects via the 
>>>>> algebraic effects approach. It's not easy to do in a high-performance 
>>>>> way, 
>>>>> because you need a call/cc construct present in the language, and 
>>>>> moreover 
>>>>> a 'multi-shot' one at that (i.e. the continuation *may* be invoked zero, 
>>>>> once or more times by the effect interpreter). In ATS a simpler way is to 
>>>>> use template functions to define effects differently (e.g. during testing 
>>>>> and during the actual execution) -- it's constrained compared to the 
>>>>> call/cc for sure, but then you don't have to pay the price of the call/cc 
>>>>> plumbing. Another thing about PureScript is that it uses row types to 
>>>>> track 
>>>>> the set of effects that a given Eff computation may involve during its 
>>>>> evaluation.
>>>>>
>>>>
>>>> Not that it will invalidate anything you just said, but the above code 
>>>> was Idris, but they may be similar in this regard (not sure). I need to 
>>>> look into call/cc more at some point - not very familiar with this idea. 
>>>> But I like where you are going with templates in ATS!
>>

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
Hi Hongwei,

On Tuesday, March 26, 2019 at 3:22:41 PM UTC+2, gmhwxi wrote:
>
> Here is a linear version:
>
> https://pastebin.com/sqXcRhnf
>
> Also, Command is a linear datatype (i.e., dataviewtype).
>
>
Great! Now, what about boxing, can we do something with boxing? I expect 
such code, if it's really used in practice, to involve LOTS of these little 
objects. So it will probably behave badly if every call to a continuation 
involves a heap allocation... Let us be a bit more resource-conscious, 
please. :)

I did a similar example a while back where I used some CPS style to get rid 
of boxing:

https://github.com/ashalkhakov/tfc/blob/master/src/SATS/cont.sats

Basically we can 'co-opt' the ATS compiler to do all the plumbing. The 
closure call and its packing is non-uniform but the closure itself is 
uniform in size, since it's a pointer to the heap:

https://github.com/ashalkhakov/tfc/blob/master/test/threads.dats

To call a continuation, the return type must be statically known (at both 
the callee side and the caller side).

So maybe we can do something similar here?
 
>
>
> On Tue, Mar 26, 2019 at 9:02 AM Hongwei Xi > 
> wrote:
>
>> Nice!
>>
>> But I am very surprised that this code actually works.
>> My understanding is that It works because of a bug in patsopt :)
>>
>> Basically, runCommand should be implemented as a polymorphic function 
>> (instead of a function
>> template). And 'a:t0ype' should be 'a:type'.
>>
>> fun runCommand: {a:type} Command(a) -> a
>>
>> Actually, I think that Command should be a linear type, which should you 
>> more fun!
>>
>> On Tue, Mar 26, 2019 at 5:49 AM Artyom Shalkhakov > > wrote:
>>
>>> I've made a gist:
>>>
>>> https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056
>>>
>>> It actually works. It illustrates the basics (sequencing, bind, input 
>>> and output). Nice. It doesn't have Haskell's "return" though, but that is 
>>> pretty simple to add (it's something that "creates" IO where there is no IO 
>>> at all...).
>>>
>>> The interpreter is using a continuation in the end. I chose this style 
>>> because the closure-function (i.e. our continuation) can be passed around 
>>> freely, whereas with a flat unboxed type it is sometimes difficult for the 
>>> C compiler to figure out the size of the variable.
>>>
>>> On Tuesday, March 26, 2019 at 10:11:11 AM UTC+2, Artyom Shalkhakov wrote:
>>>
>>>> Hi Brandon,
>>>>
>>>> On Friday, March 22, 2019 at 8:49:29 PM UTC+2, Brandon Barker wrote:
>>>>>
>>>>> Hey Artyom,
>>>>>
>>>>> Thanks for the very interesting analysis and response.
>>>>>
>>>>>
>>>> Glad you found it useful!
>>>>
>>>> On Fri, Mar 22, 2019 at 4:06 AM Artyom Shalkhakov <
>>>>> artyom.s...@gmail.com> wrote:
>>>>>
>>>>>> Hi Brandon,
>>>>>>
>>>>>> This is a very lively discussion, thanks for bringing it up.
>>>>>>
>>>>>> On Friday, March 22, 2019 at 5:48:07 AM UTC+2, Brandon Barker wrote:
>>>>>>>
>>>>>>> And for what it's worth, here is an Idris program for haha using 
>>>>>>> Effects:
>>>>>>>
>>>>>>> module Main
>>>>>>>
>>>>>>>
>>>>>>> import Effects
>>>>>>> import Effect.StdIO
>>>>>>>
>>>>>>>
>>>>>>> hello : Eff () [STDIO]
>>>>>>> hello = let ha = StdIO.putStr "ha" in ha *> ha
>>>>>>>
>>>>>>>
>>>>>>> main : IO ()
>>>>>>> main = run hello
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> It prints "ha" twice, despite being a strict language. I presume, 
>>>>>>> but am not sure, this is because the effect time requires it to be 
>>>>>>> re-evaluated each time.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Well, the type of "hello" says that the computation will use the 
>>>>>> STDIO effect as many times as is necessary. The way the computation is 
>>>>>> constructed, it is meant to issue commands in a given sequence.
>>>>>>
>>>>>

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
I've made a gist:

https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056

It actually works. It illustrates the basics (sequencing, bind, input and 
output). Nice. It doesn't have Haskell's "return" though, but that is 
pretty simple to add (it's something that "creates" IO where there is no IO 
at all...).

The interpreter is using a continuation in the end. I chose this style 
because the closure-function (i.e. our continuation) can be passed around 
freely, whereas with a flat unboxed type it is sometimes difficult for the 
C compiler to figure out the size of the variable.

On Tuesday, March 26, 2019 at 10:11:11 AM UTC+2, Artyom Shalkhakov wrote:

> Hi Brandon,
>
> On Friday, March 22, 2019 at 8:49:29 PM UTC+2, Brandon Barker wrote:
>>
>> Hey Artyom,
>>
>> Thanks for the very interesting analysis and response.
>>
>>
> Glad you found it useful!
>
> On Fri, Mar 22, 2019 at 4:06 AM Artyom Shalkhakov  
>> wrote:
>>
>>> Hi Brandon,
>>>
>>> This is a very lively discussion, thanks for bringing it up.
>>>
>>> On Friday, March 22, 2019 at 5:48:07 AM UTC+2, Brandon Barker wrote:
>>>>
>>>> And for what it's worth, here is an Idris program for haha using 
>>>> Effects:
>>>>
>>>> module Main
>>>>
>>>>
>>>> import Effects
>>>> import Effect.StdIO
>>>>
>>>>
>>>> hello : Eff () [STDIO]
>>>> hello = let ha = StdIO.putStr "ha" in ha *> ha
>>>>
>>>>
>>>> main : IO ()
>>>> main = run hello
>>>>
>>>>
>>>>
>>>> It prints "ha" twice, despite being a strict language. I presume, but 
>>>> am not sure, this is because the effect time requires it to be 
>>>> re-evaluated 
>>>> each time.
>>>>
>>>>
>>>>
>>> Well, the type of "hello" says that the computation will use the STDIO 
>>> effect as many times as is necessary. The way the computation is 
>>> constructed, it is meant to issue commands in a given sequence.
>>>
>>> One peculiarity of PureScript is that of handling effects via the 
>>> algebraic effects approach. It's not easy to do in a high-performance way, 
>>> because you need a call/cc construct present in the language, and moreover 
>>> a 'multi-shot' one at that (i.e. the continuation *may* be invoked zero, 
>>> once or more times by the effect interpreter). In ATS a simpler way is to 
>>> use template functions to define effects differently (e.g. during testing 
>>> and during the actual execution) -- it's constrained compared to the 
>>> call/cc for sure, but then you don't have to pay the price of the call/cc 
>>> plumbing. Another thing about PureScript is that it uses row types to track 
>>> the set of effects that a given Eff computation may involve during its 
>>> evaluation.
>>>
>>
>> Not that it will invalidate anything you just said, but the above code 
>> was Idris, but they may be similar in this regard (not sure). I need to 
>> look into call/cc more at some point - not very familiar with this idea. 
>> But I like where you are going with templates in ATS!
>>
>
>
> Haha, right! I mixed them up. I do remember reading about effects in both 
> languages! And I think they are pretty similar, except in Idris, you have a 
> type-level list of effects, whereas in PureScript, it is instead a row of 
> effects. So, pretty similar from the POV of using it. I think. :)
>  
>
>>
>>> So in short, if we view the programs as creating commands, and then some 
>>> kind of external interpreter that executes them, then it all matches up. 
>>> The programs might be quite pure and non-side-effecting (except for 
>>> non-termination aka infinite looping runtime exceptions), the interpreter 
>>> will perform the effects. Here's a pseudocode for the interpreter:
>>>
>>> // the command sub-language
>>> datatype Command = Print of string | Nop | Seq of (command, command)
>>> extern
>>> fun runCommand (c:Command): void
>>> extern
>>> fun seq (c:Command, Command): Command
>>> extern
>>> fun cprint (s:string): Command
>>> implement
>>> seq (c1, c2) = Seq (c1, c2)
>>> implement
>>> cprint (s) = Print s
>>> // the interpreter itself
>>> implement
>>> runCommand (c) = case+ c of Nop => (*done!*) | Print s => print (s) | 
>>> Seq (c

Re: Referential transparency in ATS

2019-03-26 Thread Artyom Shalkhakov
Hi Brandon,

On Friday, March 22, 2019 at 8:49:29 PM UTC+2, Brandon Barker wrote:
>
> Hey Artyom,
>
> Thanks for the very interesting analysis and response.
>
>
Glad you found it useful!

On Fri, Mar 22, 2019 at 4:06 AM Artyom Shalkhakov  > wrote:
>
>> Hi Brandon,
>>
>> This is a very lively discussion, thanks for bringing it up.
>>
>> On Friday, March 22, 2019 at 5:48:07 AM UTC+2, Brandon Barker wrote:
>>>
>>> And for what it's worth, here is an Idris program for haha using Effects:
>>>
>>> module Main
>>>
>>>
>>> import Effects
>>> import Effect.StdIO
>>>
>>>
>>> hello : Eff () [STDIO]
>>> hello = let ha = StdIO.putStr "ha" in ha *> ha
>>>
>>>
>>> main : IO ()
>>> main = run hello
>>>
>>>
>>>
>>> It prints "ha" twice, despite being a strict language. I presume, but am 
>>> not sure, this is because the effect time requires it to be re-evaluated 
>>> each time.
>>>
>>>
>>>
>> Well, the type of "hello" says that the computation will use the STDIO 
>> effect as many times as is necessary. The way the computation is 
>> constructed, it is meant to issue commands in a given sequence.
>>
>> One peculiarity of PureScript is that of handling effects via the 
>> algebraic effects approach. It's not easy to do in a high-performance way, 
>> because you need a call/cc construct present in the language, and moreover 
>> a 'multi-shot' one at that (i.e. the continuation *may* be invoked zero, 
>> once or more times by the effect interpreter). In ATS a simpler way is to 
>> use template functions to define effects differently (e.g. during testing 
>> and during the actual execution) -- it's constrained compared to the 
>> call/cc for sure, but then you don't have to pay the price of the call/cc 
>> plumbing. Another thing about PureScript is that it uses row types to track 
>> the set of effects that a given Eff computation may involve during its 
>> evaluation.
>>
>
> Not that it will invalidate anything you just said, but the above code was 
> Idris, but they may be similar in this regard (not sure). I need to look 
> into call/cc more at some point - not very familiar with this idea. But I 
> like where you are going with templates in ATS!
>


Haha, right! I mixed them up. I do remember reading about effects in both 
languages! And I think they are pretty similar, except in Idris, you have a 
type-level list of effects, whereas in PureScript, it is instead a row of 
effects. So, pretty similar from the POV of using it. I think. :)
 

>
>> So in short, if we view the programs as creating commands, and then some 
>> kind of external interpreter that executes them, then it all matches up. 
>> The programs might be quite pure and non-side-effecting (except for 
>> non-termination aka infinite looping runtime exceptions), the interpreter 
>> will perform the effects. Here's a pseudocode for the interpreter:
>>
>> // the command sub-language
>> datatype Command = Print of string | Nop | Seq of (command, command)
>> extern
>> fun runCommand (c:Command): void
>> extern
>> fun seq (c:Command, Command): Command
>> extern
>> fun cprint (s:string): Command
>> implement
>> seq (c1, c2) = Seq (c1, c2)
>> implement
>> cprint (s) = Print s
>> // the interpreter itself
>> implement
>> runCommand (c) = case+ c of Nop => (*done!*) | Print s => print (s) | Seq 
>> (c1, c2) => (runCommand(c1); runCommand(c2))
>>
>> Now let's assume the Command is abstract for the rest of the program (and 
>> only the runCommand, seq and print are exposed). We can now write:
>>
>> val hello = let val h = cprint "hi" in seq (h, h) end // here. twice the 
>> effect!
>> implement
>> main0 () = runCommand hello
>>
>> The "hello" itself is free of side-effects (or so it seems to me!). We 
>> might need to lazily evaluate stuff here (e.g. to enable looping, where you 
>> need to give the interpreter the chance to run side-by-side with your 
>> expression). Or we need a more poweful "seq" (i.e. the Haskell's "bind" 
>> operator for stitching together the commands such that the left-hand side 
>> has to be evaluated to a value that is then fed to the right-hand side -- 
>> i.e. incrementally built-up as it's being evaluated by the interpeter).
>>
>> In Haskell, the type Command is termed "IO" (with an additional type 
>> parameter to sign

Re: Difference between `!T` and `!T >> _`?

2019-03-21 Thread Artyom Shalkhakov
On Monday, March 18, 2019 at 7:19:46 AM UTC+2, Shimin Guo wrote:
>
> For !T, INT2PROGINATS says:
>
> Note that the symbol ! in front of the type of a function argument 
> indicates that the argument is call-by-value and it is preserved after a 
> call to the function.
>
>
> For !T >> _, INT2PROGINATS says:
>
> Given a type T, the notation (!T >> _) is a shorthand for (!T >> T).
>
>
> How are they different?
>

To put in context of programming activity, if T is something complex, then 
having this shorthand is a really good idea: with it, you don't have to 
type the type twice. Don't you like the grammatical structure of the last 
sentence. :-)

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/bd26a046-65ad-4a33-822d-adb06391d29a%40googlegroups.com.


Re: Call-by-value assignment

2019-02-24 Thread Artyom Shalkhakov
Hi, M88 and Hongwei,

On Sunday, February 24, 2019 at 5:45:34 PM UTC+2, gmhwxi wrote:
>
> The following line is problematic:
>
> prval () = $effmask_all(x := env)
>
> as assignment is definitely not a proof.
>
> I suggest that you just do
>
> val () = x := env
>
> The compiler should allocate the same memory for both x and env.
>

Flat viewtypes are represented by plain C structs in ATS, that is, they are 
directly copyable. I think this should give the C compiler a hint.
 

> Theoretically, you could separate x into two parts: data and (linear) 
> proof;
> only move the data into env; there is no need to move the data back from 
> env
> into x since the data is non-linear. Really not worth the trouble :)
>

In practice, records are really tough to handle this way (especially the 
initialization and free -- casts galore! :)).

 

>
>
> On Sun, Feb 24, 2019 at 2:52 AM M88 > 
> wrote:
>
>> Hello,
>>
>> I have a viewtype and I am using it in a call-by-value function.  I want 
>> to temporarily assign it to a variable for use in a template that uses 
>> call-by-reference.
>>
>> Is there a way to assert that the variable has not been consumed? 
>>
>> Right now I am doing this, which typechecks and compiles in my case:
>>
>> extern fun {env}
>> some_template( env :  >> _ ) : void
>>
>> fun f ( x: !VT) : void = 
>> let
>>  var env = x
>>  val _ = some_template(env)
>>  prval () = $effmask_all(
>> x := env
>>   )
>> in
>>end
>>
>> Is this expected behavior?  Is it possible to write a proof function that 
>> can restore "x"? 
>>
>> ( Ultimately, x does not change, and the semantics of call-by-value seem 
>> best for this function ).
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ats-lang-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ats-lang-user...@googlegroups.com .
>> To post to this group, send email to ats-lan...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/ce57d10d-cb0a-465f-b9f6-954d7d6678cb%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/47a5462b-c081-4b1b-a5d3-c135b96b2eec%40googlegroups.com.


Re: Stack-allocated arrays in ATS2 (or ATS3?)

2019-02-23 Thread Artyom Shalkhakov
Hi Vanessa!

On Saturday, February 23, 2019 at 1:11:31 PM UTC+2, Vanessa McHale wrote:
>
> Is there any way to safely use alloca in ATS? I know the language has 
> features for both safe pointer arithmetic and safe use of 
> stack-allocated variables... so it would be nice to both guarantee no
> out-of-bounds array accesses and no subsequent uses of the pointer. 
>
>
Have you seen this discussion:

https://groups.google.com/forum/#!searchin/ats-lang-users/alloca%7Csort:date/ats-lang-users/a9KRqQn2uGo/nUqbI_2AHn4J

As for me, I think It's OK to use the outlined approach. BTW it is already 
provided in the ATS2 libats/libc.
 
>
> Cheers, 
> Vanessa McHale 
>
>
>
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/21a8481c-b866-4615-a0fc-098dec164d6f%40googlegroups.com.


Re: ATS2 -> ATS3 Migration Effort

2019-01-21 Thread Artyom Shalkhakov
The previous time migration was mostly painless. There were some changes 
for sure but most code could be translated either outright trivially, or 
mostly straightforwardly.

Off the top of my head, most changes were:

1. different syntax for dataviewtypes and a different default when 
pattern-matching
2. some tooling was not ported (i.e. atsdoc and atslex)
3. the addition of function template obsoleted many uses of higher-order 
functions
4. minor changes to naming of prelude functions / more uses of function 
templates instead of higher-order functions

On Tuesday, January 15, 2019 at 4:37:27 PM UTC+2, aditya siram wrote:
>
> I know it's early to ask this but do you anticipate a large migration 
> effort between ATS2 and ATS3? Are you planning to change significant 
> portions of the syntax, cut any large features etc? I'm working on 
> something that's liable to grow to 7-10,000 LOC and trying to figure out if 
> I should wait for ATS3.
>
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/f602db71-c55a-493e-9c4e-db02dfd7f571%40googlegroups.com.


ATS3 metaprogramming and Spiral language

2019-01-08 Thread Artyom Shalkhakov
Hi all,

I find this Spiral language interesting:

https://github.com/mrakgr/The-Spiral-Language

It's probably easy to write a program that will take ages to compile,
though.

I really wish ATS3 had improved on templates and on macros. :-)

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqgqvtRPtN4rBJMm-15Pcyo7b3BaOqYO0K%3DxQqP6h4itdA%40mail.gmail.com.


Re: Tuple parsing bug.

2019-01-03 Thread Artyom Shalkhakov
чт, 3 янв. 2019 г. в 14:58, aditya siram :

> Hi,
> The following seems like a bug, a tuple template parameter can't be
> parsed. The following:
>
> fun {a: t0p}{b : t0p} id(i : b) = i
> implement main0(argc,argv) =
>   let
> val _ = id<@(int,int)>((1,2))
>   in
> ()
>   end
>
>
>
> generates the error:
>
> ... 1596(line=69, offs=19) -- 1599(line=69, offs=22): error(2): the static
> identifier [><@] is unrecognized.
> ... 1593(line=69, offs=16) -- 1608(line=69, offs=31): error(2): none of
> the static constants referred to by [int] is applicable.
> patsopt(TRANS2): there are [2] errors in total.
> exit(ATS): uncaught exception: ...
>
>
>
>
> But if I add a space before the '@' it works:
>
> implement main0(argc,argv) =
>   let
> val _ = id< @(int,int)>((1,2)) (* note the space before '@' *)
>   in
> ()
>   end
>
>
It's a known issue, but thanks for highlighting it. Enclosing @(int,int) in
parentheses should also work.


> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/d0a0a8e5-fccf-4840-af60-505e55998dcc%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/d0a0a8e5-fccf-4840-af60-505e55998dcc%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqimXMWHRyTXdkt%2Bdv1n5bZ%2Bnj7FfP6sTxubM1936PqaVg%40mail.gmail.com.


Re: Merging stream_vt

2019-01-02 Thread Artyom Shalkhakov
Hi Richard,

ср, 2 янв. 2019 г. в 17:35, Richard :

> Yes, this compiles and runs as expected. Although, I am not sure that I
> have ever used 'stream_vt_con_free'. A slightly different way to do the
> same without using stream_vt_con_free,
>
>
>
> #include "share/atspre_staload.hats"
>
> extern fun {a:t@ype}{b:t@ype}
>   merge : (stream_vt a, stream_vt b) -> stream_vt(@(a,b))
>
> implement{a}{b} merge (xs, ys) = let
> fun
> auxmain (xs: stream_vt a, ys: stream_vt b) : stream_vt(@(a,b)) = $ldelay
> (
> (
>   case+ !xs of
>   | ~stream_vt_nil() => (~ys; stream_vt_nil())
>   | ~stream_vt_cons(x, xs) =>
> case+ !ys of
> | ~stream_vt_nil() => (~xs; stream_vt_nil())
> | ~stream_vt_cons(y, ys) =>
>   stream_vt_cons(@(x, y), auxmain(xs, ys))
> ) ,
> (
>   ~xs; ~ys
> )
> )
> in
>   auxmain(xs, ys)
> end
>
>
>
>
My guess is that the prefix ~ operator is the "stream_vt_free". :-) I did
not know it has an operator attached to it, thanks for pointing it out!


>
> To test,
>
> implement main0() =
> {
>   val xs = streamize_list_vt_elt($list_vt{int}(1, 2))
>   val ys = streamize_list_vt_elt($list_vt{string}("x", "y"))
>
>   val zs = merge (xs, ys)
>
>   val l = stream2list_vt (zs)
>   val () = println!(l) // should print something like: 1,x; 2,y
>
>   val () = list_vt_free(l)
> }
>
>
>
>
> On Wednesday, January 2, 2019 at 3:00:17 AM UTC-5, Artyom Shalkhakov wrote:
>>
>> ср, 2 янв. 2019 г. в 09:41, aditya siram :
>>
>>> Awesome. That does typecheck but when I try to build it with:
>>>
>>> "$PATSHOME/bin/patscc" -O3 -flto -s -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -
>>> I${PATSHOME}/contrib -O3 -o triples triples.dats -latslib
>>>
>>>
>>>
>> I don't have a compiler with me here but it seems like the function
>> should be made into a template (i.e. the type parameters should be put
>> prior to the function's name in the declaration).
>>
>> This typechecks and the online compiler will accept it:
>>
>> fun test (): void = {
>>   val xs = stream_vt_make_cons ((g0ofg1)1, stream_vt_make_cons
>> ((g0ofg1)2, stream_vt_make_nil{int} ()))
>>
>>   val ys = stream_vt_make_cons ((g0ofg1)"x", stream_vt_make_cons
>> ((g0ofg1)"y", stream_vt_make_nil{string} ()))
>>
>>   val zs = merge (xs, ys)
>>
>>   val l = stream2list_vt (zs)
>>   val () = println!(l) // should print something like: 1,x; 2,y
>>
>>   val () = list_vt_free(l)
>> }
>>
>> Unfortunately I can't run it (the glot.io-provided compiler doesn't
>> support stream_vt_make_* functions).
>>
>>
>>> I get:
>>>
>>> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35
>>> : error: assignment to expression with array type
>>>  #define ATSINSmove(tmp, val) (tmp = val)
>>>^
>>> triples_dats.c:1062:1: note: in expansion of macro ‘ATSINSmove’
>>>  ATSINSmove(tmp19, ATSSELcon(env0, postiats_tysum_3, atslab__0)) ;
>>>  ^~
>>> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35
>>> : error: assignment to expression with array type
>>>  #define ATSINSmove(tmp, val) (tmp = val)
>>>^
>>> triples_dats.c:1070:1: note: in expansion of macro ‘ATSINSmove’
>>>  ATSINSmove(tmp21, ATSSELcon(env1, postiats_tysum_4, atslab__0)) ;
>>>  ^~
>>> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:327:65
>>> : error: assignment to expression with array type
>>>  #define ATSINSstore_fltrec_ofs(tmp, tyrec, lab, val) ((tmp).lab = val)
>>>  ^
>>> triples_dats.c:1093:1: note: in expansion of macro ‘
>>> ATSINSstore_fltrec_ofs’
>>>  ATSINSstore_fltrec_ofs(tmp23, postiats_tyrec_2, atslab__0, tmp19) ;
>>>  ^~
>>> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:327:65
>>> : error: assignment to expression with array type
>>>  #define ATSINSstore_fltrec_ofs(tmp, tyrec, lab, val) ((tmp).lab = val)
>>>  ^
>>> triples_dats.c:1094:1: note: in expansion of macro ‘
>>> ATSINSstore_fltrec_ofs’
>>>  ATSINSstore_fltrec_ofs(tmp23, postiats_tyrec_2, atslab__1, tmp21) ;
>>>  ^~
>>>
>>&

Re: Merging stream_vt

2019-01-02 Thread Artyom Shalkhakov
ср, 2 янв. 2019 г. в 09:41, aditya siram :

> Awesome. That does typecheck but when I try to build it with:
>
> "$PATSHOME/bin/patscc" -O3 -flto -s -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -I${
> PATSHOME}/contrib -O3 -o triples triples.dats -latslib
>
>
>
I don't have a compiler with me here but it seems like the function should
be made into a template (i.e. the type parameters should be put prior to
the function's name in the declaration).

This typechecks and the online compiler will accept it:

fun test (): void = {
  val xs = stream_vt_make_cons ((g0ofg1)1, stream_vt_make_cons ((g0ofg1)2,
stream_vt_make_nil{int} ()))

  val ys = stream_vt_make_cons ((g0ofg1)"x", stream_vt_make_cons
((g0ofg1)"y", stream_vt_make_nil{string} ()))

  val zs = merge (xs, ys)

  val l = stream2list_vt (zs)
  val () = println!(l) // should print something like: 1,x; 2,y

  val () = list_vt_free(l)
}

Unfortunately I can't run it (the glot.io-provided compiler doesn't support
stream_vt_make_* functions).


> I get:
>
> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35:
> error: assignment to expression with array type
>  #define ATSINSmove(tmp, val) (tmp = val)
>^
> triples_dats.c:1062:1: note: in expansion of macro ‘ATSINSmove’
>  ATSINSmove(tmp19, ATSSELcon(env0, postiats_tysum_3, atslab__0)) ;
>  ^~
> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:276:35:
> error: assignment to expression with array type
>  #define ATSINSmove(tmp, val) (tmp = val)
>^
> triples_dats.c:1070:1: note: in expansion of macro ‘ATSINSmove’
>  ATSINSmove(tmp21, ATSSELcon(env1, postiats_tysum_4, atslab__0)) ;
>  ^~
> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:327:65:
> error: assignment to expression with array type
>  #define ATSINSstore_fltrec_ofs(tmp, tyrec, lab, val) ((tmp).lab = val)
>  ^
> triples_dats.c:1093:1: note: in expansion of macro ‘ATSINSstore_fltrec_ofs
> ’
>  ATSINSstore_fltrec_ofs(tmp23, postiats_tyrec_2, atslab__0, tmp19) ;
>  ^~
> /home/deech/ATS/test/ATS/ATS2/ccomp/runtime/pats_ccomp_instrset.h:327:65:
> error: assignment to expression with array type
>  #define ATSINSstore_fltrec_ofs(tmp, tyrec, lab, val) ((tmp).lab = val)
>  ^
> triples_dats.c:1094:1: note: in expansion of macro ‘ATSINSstore_fltrec_ofs
> ’
>  ATSINSstore_fltrec_ofs(tmp23, postiats_tyrec_2, atslab__1, tmp21) ;
>  ^~
>
>
>
>
> On Wednesday, January 2, 2019 at 1:21:24 AM UTC-6, Artyom Shalkhakov wrote:
>>
>> Hello Aditya!
>>
>> I've modified this a bit by inserting freeing:
>>
>> fun merge
>>   {a: t@ype}
>>   {b: t@ype}
>>   (
>> s1: stream_vt a,
>> s2: stream_vt b
>>   ) : stream_vt(@(a,b)) =
>>   let
>> val _s1 = !s1
>> val _s2 = !s2
>>   in
>> $ldelay
>>  (
>>   (
>>   case+ (_s1,_s2) of
>>   | (~stream_vt_cons(_s1e, _s1s),
>>  ~stream_vt_cons(_s2e, _s2s)) =>
>>  stream_vt_cons(@(_s1e,_s2e), merge(_s1s,_s2s))
>>   | (~stream_vt_nil (), _) => (stream_vt_con_free(_s2);
>> stream_vt_nil())
>>   | (_, ~stream_vt_nil ()) => (stream_vt_con_free(_s1);
>> stream_vt_nil())
>>   )
>>  , (stream_vt_con_free(_s1); stream_vt_con_free(_s2))
>>  )
>>   end
>>
>> This type-checks (but I have not run it).
>>
>> $ldelay requires us to supply as its second argument an expression that
>> will free up all resources that are used in its first argument.
>>
>> ср, 2 янв. 2019 г. в 08:10, aditya siram :
>>
>>> I trying to understand the stream_vt datatype by writing a function
>>> that merges two streams in a stream of tuples but not having much luck, the
>>> following:
>>>
>>> fun merge
>>>   {a: t@ype}
>>>   {b: t@ype}
>>>   (
>>> s1: stream_vt a,
>>> s2: stream_vt b
>>>   ) : stream_vt(@(a,b)) =
>>>   let
>>> val _s1 = !s1
>>> val _s2 = !s2
>>>   in
>>> $ldelay
>>>  (
>>>   case+ (_s1,_s2) of
>>>   | (~stream_vt_cons(_s1, _s1s),
>>>  ~stream_vt_cons(_s2, _s2s)) =>
>>>  stream_vt_cons((_s1,_s2), merge(_s1s,_s2s))
>>>   | (_,_) => stream_vt_nil()
>>>  )
>>>   end
>>>
>>> gives me the errors:
>>>
&

Re: Merging stream_vt

2019-01-01 Thread Artyom Shalkhakov
Hello Aditya!

I've modified this a bit by inserting freeing:

fun merge
  {a: t@ype}
  {b: t@ype}
  (
s1: stream_vt a,
s2: stream_vt b
  ) : stream_vt(@(a,b)) =
  let
val _s1 = !s1
val _s2 = !s2
  in
$ldelay
 (
  (
  case+ (_s1,_s2) of
  | (~stream_vt_cons(_s1e, _s1s),
 ~stream_vt_cons(_s2e, _s2s)) =>
 stream_vt_cons(@(_s1e,_s2e), merge(_s1s,_s2s))
  | (~stream_vt_nil (), _) => (stream_vt_con_free(_s2); stream_vt_nil())
  | (_, ~stream_vt_nil ()) => (stream_vt_con_free(_s1); stream_vt_nil())
  )
 , (stream_vt_con_free(_s1); stream_vt_con_free(_s2))
 )
  end

This type-checks (but I have not run it).

$ldelay requires us to supply as its second argument an expression that
will free up all resources that are used in its first argument.

ср, 2 янв. 2019 г. в 08:10, aditya siram :

> I trying to understand the stream_vt datatype by writing a function that
> merges two streams in a stream of tuples but not having much luck, the
> following:
>
> fun merge
>   {a: t@ype}
>   {b: t@ype}
>   (
> s1: stream_vt a,
> s2: stream_vt b
>   ) : stream_vt(@(a,b)) =
>   let
> val _s1 = !s1
> val _s2 = !s2
>   in
> $ldelay
>  (
>   case+ (_s1,_s2) of
>   | (~stream_vt_cons(_s1, _s1s),
>  ~stream_vt_cons(_s2, _s2s)) =>
>  stream_vt_cons((_s1,_s2), merge(_s1s,_s2s))
>   | (_,_) => stream_vt_nil()
>  )
>   end
>
> gives me the errors:
>
> ...: 465(line=27, offs=9) -- 590(line=29, offs=57): error(3): the dynamic
> variable [_s2$4720(-1)] is consumed but it should be retained with the
> type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(b(8451)))] instead.
> ...: 465(line=27, offs=9) -- 590(line=29, offs=57): error(3): the dynamic
> variable [_s1$4719(-1)] is consumed but it should be retained with the
> type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(a(8450)))] instead.
> ...: 368(line=20, offs=3) -- 636(line=32, offs=6): error(3): the linear
> dynamic variable [_s1$4719(-1)] needs to be consumed but it is preserved
> with the type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(a(8450)))] instead.
> ...: 368(line=20, offs=3) -- 636(line=32, offs=6): error(3): the linear
> dynamic variable [_s2$4720(-1)] needs to be consumed but it is preserved
> with the type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(b(8451)))] instead.
> patsopt(TRANS3): there are [4] errors in total.
> exit(ATS): uncaught exception:
> _2home_2deech_2ATS_2triples_2dats_2ATS_2ATS2_2src_2pats_error_2esats__FatalErrorExn
> (1025)
>
> Any help is appreciated.
>
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/21f9263f-e0be-4dcb-8bf6-45031eaea85a%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/21f9263f-e0be-4dcb-8bf6-45031eaea85a%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqgfQxJLCtbw2j2r7sd6fJwenYw5h31LRmp0zkjEg-t6pQ%40mail.gmail.com.


Re: Happy Holidays!

2018-12-26 Thread Artyom Shalkhakov

Hello Hongwei!

On Вт, дек 25, 2018 at 6:31 , gmhwxi  wrote:


This mailing-list has been somewhat quiet recently.

I'd like to use this occasion to wish everyone well and also to 
prosper in the

upcoming new year!


Thank you very much! I would also to congratulate you and the other 
members of the list with Christmas and wish everybody to put things 
things in proper order this year. :-)


I als like to thank you personally and wholeheartedly for your work on 
ATS over these years. Wish you to keep it up!


I have been working on ATS3 for quite some time. So far the progress 
has been
slow (but steady). As you all know, ATS has been first and foremost 
an academic
project and implemented as such. Now I want to make ATS3 a lot more 
polished
than ATS2, hoping it would have a better chance to become mainstream. 
I am designing
and implementing ATS3 in ways that should make it easy for other 
people to contribute
in the future. In particular, I have been experimenting with ways to 
better report error messages

in ATS3.


That's great news!

To reiterate, ATS3 is perceived to be both a source language and a 
target language
(at the same level as C). And extensive meta-programming support is 
to be built on top

of ATS3.

Right now, I am in the middle of implementing sort-checking (that is, 
type-checking for
the statics of ATS). After that, I will start to implement 
type-inference (for non-dependent
types). My current plan is to get ATS3 running some time next year 
(hopefully, by the end of

summer).

There will be plenty collaboration opportunities soon.


I'm awaiting eagerly! Unfortunately my time is now split such that I 
now have to find more inventive ways to program as a hobby (but this is 
probably the situation among most, if not all, people on the list).



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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/44084646-8b94-4c38-8e1d-73edf47a1de8%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/1545820208.1825.0%40smtp.gmail.com.


Re: where do I get atscc2js from?

2018-11-07 Thread Artyom Shalkhakov
Hi Dmitry,

ср, 7 нояб. 2018 г. в 12:18, Dmitry Kouznetsov :

> I do have PATSHOME set, however PATSHOMERELOC isn't set. What is it
> supposed to be set to? btw I am using Mac, should it matter.
>
>
PATSHOMERELOC should be set to the full path to the ATS2-contrib repo clone.

On Wednesday, November 7, 2018 at 8:51:41 AM UTC+1, Artyom Shalkhakov wrote:
>>
>> On Tuesday, November 6, 2018 at 6:28:46 PM UTC+2, Dmitry Kouznetsov wrote:
>>>
>>> So, now I have the following output:
>>>
>>>
>> Curious. Do you have PATSHOME and PATSHOMERELOC environment variables set?
>>
>> These kinds of errors typically indicate that the compiler was unable to
>> locate template function definitions. For the first error, the offending
>> code is probably
>>
>>
>> https://github.com/githwxi/ATS-Postiats/blob/master/contrib/CATS-parsemit/DATS/catsparse_symbol.dats#L104
>>
>> but I guess that unsafe function definitions should have been supplied in
>> the prelude.
>>
>>
>>> ⋊> ~/s/a/A/c/CATS-atscc2js on master ⨯ *make* all
>>>
>>> 17:26:14
>>>
>>> \
>>>
>>> make -C CATS-parsemit all
>>>
>>> make[1]: Nothing to be done for `all'.
>>>
>>> \
>>>
>>> /Users/dmitry/sandbox/ats/ATS2-Postiats//bin/patscc \
>>>
>>>   -O2 -DATS_MEMALLOC_GCBDW -o bin/atscc2js \
>>>
>>>DATS/atscc2js_main.dats DATS/atscc2js_emit.dats
>>> DATS/atscc2js_emit2.dats  ./CATS-parsemit/SATS/catsparse.sats  
>>> ./CATS-parsemit/CATS/catsparse_all_dats.c
>>> -lgc
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:68880:51: **warning: **implicit
>>> declaration of function 'S2Ecst' is invalid in C99
>>> [-Wimplicit-function-declaration]*
>>>
>>> ATSINSmove(tmpret2067,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2068)) ;
>>>
>>> *  ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:68880:58: **error: **use of
>>> undeclared identifier 'symbol'*
>>>
>>> ATSINSmove(tmpret2067,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2068)) ;
>>>
>>> * ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:68880:42: **error: **use of
>>> undeclared identifier 'cptr_get'*
>>>
>>> ATSINSmove(tmpret2067,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2068)) ;
>>>
>>> * ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:68880:66: **error: **expected
>>> expression*
>>>
>>> ATSINSmove(tmpret2067,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2068)) ;
>>>
>>> * ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:68880:24: **error: **use of
>>> undeclared identifier 'PMVtmpltcstmat'*
>>>
>>> ATSINSmove(tmpret2067,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2068)) ;
>>>
>>> *   ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:71716:51: **warning: **implicit
>>> declaration of function 'S2Ecst' is invalid in C99
>>> [-Wimplicit-function-declaration]*
>>>
>>> ATSINSmove(tmpret2190,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2191)) ;
>>>
>>> *  ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:71716:58: **error: **use of
>>> undeclared identifier 'filename_type'*
>>>
>>> ATSINSmove(tmpret2190,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2191)) ;
>>>
>>> * ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:71716:42: **error: **use of
>>> undeclared identifier 'cptr_get'*
>>>
>>> ATSINSmove(tmpret2190,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2191)) ;
>>>
>>> * ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:71716:73: **error: **expected
>>> expression*
>>>
>>> ATSINSmove(tmpret2190,
>>> PMVtmpltcstmat[0](cptr_get)(tmp2191)) ;
>>>
>>> *
>>> ^*
>>>
>>> *./CATS-parsemit/CATS/catsparse_all_dats.c:71716:24: **error: **use of
>>> undeclared identifier 'PMVtmpltcstmat'*
>>>
>>> ATSINSmove(tmpret2190,
>>&

Re: where do I get atscc2js from?

2018-11-06 Thread Artyom Shalkhakov
*./CATS-parsemit/CATS/catsparse_all_dats.c:71781:21: **error: **use of 
> undeclared identifier 'PMVtmpltcstmat'*
>
> ATSINSmove(tmp2197, 
> PMVtmpltcstmat[0](cptr_get)(tmp2195)) ;
>
> *^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:97729:51: **warning: **implicit 
> declaration of function 'S2Ecst' is invalid in C99 
> [-Wimplicit-function-declaration]*
>
> ATSINSmove(tmpret3537, 
> PMVtmpltcstmat[0](cptr_get)(tmp3538)) ;
>
> *  ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:97729:58: **error: **use of 
> undeclared identifier 'keyword'*
>
> ATSINSmove(tmpret3537, 
> PMVtmpltcstmat[0](cptr_get)(tmp3538)) ;
>
> * ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:97729:42: **error: **use of 
> undeclared identifier 'cptr_get'*
>
> ATSINSmove(tmpret3537, 
> PMVtmpltcstmat[0](cptr_get)(tmp3538)) ;
>
> * ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:97729:67: **error: **expected 
> expression*
>
> ATSINSmove(tmpret3537, 
> PMVtmpltcstmat[0](cptr_get)(tmp3538)) ;
>
> *  ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:97729:24: **error: **use of 
> undeclared identifier 'PMVtmpltcstmat'*
>
> ATSINSmove(tmpret3537, 
> PMVtmpltcstmat[0](cptr_get)(tmp3538)) ;
>
> *   ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:98757:51: **warning: **implicit 
> declaration of function 'S2Etyrec' is invalid in C99 
> [-Wimplicit-function-declaration]*
>
> ATSINSmove(tmpret3567, PMVtmpltcstmat[0](cptr_get lexerr_loc=S2Ecst(loc_t), lexerr_node=S2Ecst(lexerr_node))>)(tmp3568)) ;
>
> *  ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:98757:60: **error: **use of 
> undeclared identifier 'box'*
>
> ATSINSmove(tmpret3567, PMVtmpltcstmat[0](cptr_get lexerr_loc=S2Ecst(loc_t), lexerr_node=S2Ecst(lexerr_node))>)(tmp3568)) ;
>
> *   ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:98757:42: **error: **use of 
> undeclared identifier 'cptr_get'*
>
> ATSINSmove(tmpret3567, PMVtmpltcstmat[0](cptr_get lexerr_loc=S2Ecst(loc_t), lexerr_node=S2Ecst(lexerr_node))>)(tmp3568)) ;
>
> * ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:98757:111: **warning: **implicit 
> declaration of function 'S2Ecst' is invalid in C99 
> [-Wimplicit-function-declaration]*
>
> ATSINSmove(tmpret3567, PMVtmpltcstmat[0](cptr_get lexerr_loc=S2Ecst(loc_t), lexerr_node=S2Ecst(lexerr_node))>)(tmp3568)) ;
>
> *          
> ^*
>
> *./CATS-parsemit/CATS/catsparse_all_dats.c:98757:118: **error: **use of 
> undeclared identifier 'lexerr_node'*
>
> ATSINSmove(tmpret3567, PMVtmpltcstmat[0](cptr_get lexerr_loc=S2Ecst(loc_t), lexerr_node=S2Ecst(lexerr_node))>)(tmp3568)) ;
>
> * 
>     ^*
>
> *fatal error: *too many errors emitted, stopping now [-ferror-limit=]
>
> 6 warnings and 20 errors generated.
>
> make: *** [bin_atscc2js] Error 1
>
> On Tuesday, November 6, 2018 at 5:25:32 PM UTC+1, Artyom Shalkhakov wrote:
>>
>> How did you install the compiler? Have you not built from source?
>>
>> The translators are probably not included in the distribution. Have to 
>> check.
>>
>> On Tue, Nov 6, 2018, 6:22 PM Dmitry Kouznetsov  
>> wrote:
>>
>>> Aha! But then that contrib dir doesn't come with git clone... Ain't I 
>>> supposed to have all the stuff from that dir in order to be able to run 
>>> that make?
>>>
>>> On Tuesday, November 6, 2018 at 5:01:11 PM UTC+1, Artyom Shalkhakov 
>>> wrote:
>>>>
>>>> Hi Dmitry,
>>>>
>>>> Welcome!
>>>>
>>>> вт, 6 нояб. 2018 г. в 17:42, Dmitry Kouznetsov :
>>>>
>>>>> Hi, I am learning ATS and want to run examples locally. This one is 
>>>>> particularly interesting to me: 
>>>>> https://github.com/githwxi/ATS-Postiats/tree/master/doc/EXAMPLE/EFFECTIVATS/FRP-bacon.js.
>>>>>  
>>>>> When I 'make all' it tells I am supposed to have atscc2js in my 
>>>>> ${PATSHOME}/bin and I don't. How do I get one?
>>>>>
>>>>
>>>> You should build it. The tr

Re: where do I get atscc2js from?

2018-11-06 Thread Artyom Shalkhakov
How did you install the compiler? Have you not built from source?

The translators are probably not included in the distribution. Have to
check.

On Tue, Nov 6, 2018, 6:22 PM Dmitry Kouznetsov 
wrote:

> Aha! But then that contrib dir doesn't come with git clone... Ain't I
> supposed to have all the stuff from that dir in order to be able to run
> that make?
>
> On Tuesday, November 6, 2018 at 5:01:11 PM UTC+1, Artyom Shalkhakov wrote:
>>
>> Hi Dmitry,
>>
>> Welcome!
>>
>> вт, 6 нояб. 2018 г. в 17:42, Dmitry Kouznetsov :
>>
>>> Hi, I am learning ATS and want to run examples locally. This one is
>>> particularly interesting to me:
>>> https://github.com/githwxi/ATS-Postiats/tree/master/doc/EXAMPLE/EFFECTIVATS/FRP-bacon.js.
>>> When I 'make all' it tells I am supposed to have atscc2js in my
>>> ${PATSHOME}/bin and I don't. How do I get one?
>>>
>>
>> You should build it. The translator is built with this Makefile:
>>
>>
>> https://github.com/githwxi/ATS-Postiats/blob/master/contrib/CATS-atscc2js/Makefile
>>
>> I think you'll have to cp the binary to $PATSHOME/bin yourself, though.
>> You can refer to some older scripts:
>>
>>
>> https://gist.github.com/ashalkhakov/4d9cc1a5fff9f9171f00a9ba50a24ebd#file-msys2-build-ats2-sh-L167
>>
>>
>>> --
>>> 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 post to this group, send email to ats-lan...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/ats-lang-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ats-lang-users/47e55746-fbe8-4ca1-9847-fcb7da889e18%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ats-lang-users/47e55746-fbe8-4ca1-9847-fcb7da889e18%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/af9af7df-fefc-452e-a0c6-eca1bd05c67e%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/af9af7df-fefc-452e-a0c6-eca1bd05c67e%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqjmgt5sY12CyJtYEtRRApw4rXp5jxSozRDp9vjnV%3Dtggg%40mail.gmail.com.


Re: where do I get atscc2js from?

2018-11-06 Thread Artyom Shalkhakov
Hi Dmitry,

Welcome!

вт, 6 нояб. 2018 г. в 17:42, Dmitry Kouznetsov :

> Hi, I am learning ATS and want to run examples locally. This one is
> particularly interesting to me:
> https://github.com/githwxi/ATS-Postiats/tree/master/doc/EXAMPLE/EFFECTIVATS/FRP-bacon.js.
> When I 'make all' it tells I am supposed to have atscc2js in my
> ${PATSHOME}/bin and I don't. How do I get one?
>

You should build it. The translator is built with this Makefile:

https://github.com/githwxi/ATS-Postiats/blob/master/contrib/CATS-atscc2js/Makefile

I think you'll have to cp the binary to $PATSHOME/bin yourself, though. You
can refer to some older scripts:

https://gist.github.com/ashalkhakov/4d9cc1a5fff9f9171f00a9ba50a24ebd#file-msys2-build-ats2-sh-L167


> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/47e55746-fbe8-4ca1-9847-fcb7da889e18%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/47e55746-fbe8-4ca1-9847-fcb7da889e18%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqiuJ-TCMP5E%2BTptn2hq09_Mnw2SJR5PQYwo%3DDXxgsNJoQ%40mail.gmail.com.


Re: Why my code occurs `unsolved constraint` error?

2018-11-05 Thread Artyom Shalkhakov
Hi Kiwamu,

Sorry for the delay, I missed your reply.

On Friday, November 2, 2018 at 5:29:00 AM UTC+2, Kiwamu Okabe wrote:
>
> Dear Hongwei and Artyom, 
>
> On Fri, Nov 2, 2018 at 12:03 PM gmhwxi > 
> wrote: 
> > The way you wrote the code makes it a bit difficult to 
> > do typechecking. Try to change the interface for utf8_to_unicode 
> > as follows: 
>
> Thanks! It's fixed! 
>
> https://travis-ci.org/metasepi/uemacs-bohai/builds/449662253 
>
> > I think the reason for having to annotate it is due to a hit on 
> performance in 
> > constraint solving. I think I read about this in one of HX's papers. 
>
> Could you tell me where is the paper? > Artyom 
>
>
The "state types" are described here:

http://www.ats-lang.org/MYDATA/Xanadu-lics00.pdf

section 4.3. The section talks about synthesizing these state types. I 
guess that ATS2 and ATS3 still follow a similar approach (since sometimes 
it's OK to drop the annotations completely and sometimes not).

I can't source my claim about performance though, sorry about that.
 

>
> What do I think such `unsolved constraint` error? 
> How to approach it? 
> Should I think "Umm it may needs more addr annotation"? 
>
> Best regards, 
> -- 
> Kiwamu Okabe at METASEPI DESIGN 
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/c6f9ce31-333a-42f2-a3b4-848669066b48%40googlegroups.com.


Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread Artyom Shalkhakov
Hi Kiwamu,

чт, 1 нояб. 2018 г. в 10:00, Kiwamu Okabe :

> Dear Artyom and Hongwei,
> sorry for my late reply.
>
> On Mon, Oct 29, 2018 at 5:17 PM Artyom Shalkhakov
>  wrote:
> > While I'm not sure why your code fails, it's an interesting project
> you've started.
>
> Thanks. It's very fun and good exercise for me.
>
> > Actually, I have an idea about your code. You may have to an annotation
> like...
>
> Thanks for your advice. But it's not clear for me...
>
> > if :( line: strnptr(m) ) => .. then ... else ... onto your conditionals.
>
> Where line of my code should follow your advice?
>
>
> https://github.com/metasepi/uemacs-bohai/blob/9ecdd06fe09e6433ed0fb4271c0e5b44d2ad8f8d/DATS/utf8.dats
>
>
You should put at at every branch (so on every [if] and on every [case]).
That's because the variable [line] is of linear type, and the annotation
basically says that in every alternative of the branch it's going to be
preserved (so, after the evaluation of an [if] or a [case] the type of
[line] is going to still be [strnptr(m)]). I think the reason for having to
annotate it is due to a hit on performance in constraint solving. I think I
read about this in one of HX's papers.

I think in your case, you'll have to annotate two [if]s:

https://github.com/metasepi/uemacs-bohai/blob/9ecdd06fe09e6433ed0fb4271c0e5b44d2ad8f8d/DATS/utf8.dats#L48
https://github.com/metasepi/uemacs-bohai/blob/9ecdd06fe09e6433ed0fb4271c0e5b44d2ad8f8d/DATS/utf8.dats#L55

Could you try it? You could also try to annotate only one [if] to find a
minimal required annotation that keeps the typechecker silent. :-)

>
> Best regards,
> --
> Kiwamu Okabe at METASEPI DESIGN
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/CAEvX6d%3Dsb8%3DkqyLc0j3bipb16_zp26FsdZ%3DfD5Q0g5k7f9ZM3g%40mail.gmail.com
> .
>


-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqh5yYagiaTtB32BD5RV_3ZwwMkJ4_thZ_%2BR-McjR_FjTw%40mail.gmail.com.


Re: Why my code occurs `unsolved constraint` error?

2018-10-29 Thread Artyom Shalkhakov
Hi Kiwamu,

While I'm not sure why your code fails, it's an interesting project you've 
started. Please don't hesitate telling us more about it!

Actually, I have an idea about your code. You may have to an annotation 
like if :( line: strnptr(m) ) => .. then ... else ... onto your 
conditionals.

On Monday, October 29, 2018 at 8:52:33 AM UTC+2, Kiwamu Okabe wrote:
>
> Dear all, 
>
> Why following code occurs `unsolved constraint` error? 
>
>
> https://github.com/metasepi/uemacs-bohai/blob/8b2b657c829be1025433f3083aa5cf3b1d040cb6/DATS/utf8.dats#L60
>  
>
> ``` 
> $ vi DATS/utf8.dats 
> --snip-- 
> implement utf8_to_unicode (pf | line, index, len, res) = bytes where { 
>   fun loop1 (c: char, mask: uint, bytes: uint): (uint, uint) = 
> if ((($UN.cast{uint}{char} c) land mask) != 0U) 
>   then loop1 (c, mask >> 1, bytes + 1U) 
>   else (mask, bytes) 
>
>   fun loop2 {m:nat} (line: !strnptr(m), i: int, len: int(m), bytes: 
> uint, value: uint): uint = 
> undefined() 
>
>   val c = line[index] 
>   val () = !res := $UN.cast{unicode_t}{char} line[index] 
>
>   (* 
>* 0xxx is valid utf8 
>* 10xx is invalid UTF-8, we assume it is Latin1 
>*) 
>   val bytes = if (c < $UN.cast{char}{int} 0xc0) 
> then 1U 
> else bytes' where { 
>   (* Ok, it's 11xx, do a stupid decode *) 
>   val (mask, bytes'') = loop1 (c, 0x20U, 0x2U) 
>
>   (* Invalid? Do it as a single byte Latin1 *) 
>   val bytes' = if (bytes'' > 6 || bytes'' > len) 
> then 1U 
> else bytes'' where { 
>   (* Ok, do the bytes *) 
>   val value = loop2 (line, 1, len, bytes'', 
>  ($UN.cast{uint}{char} c) land (mask - 1U)) 
>   val () = !res := $UN.cast{unicode_t}{uint} value 
> } 
> } 
> } 
> --snip-- 
> $ pwd 
> /home/kiwamu/src/uemacs-bohai 
> $ make 
>   ATS  utf8.dats.c 
> /home/kiwamu/src/uemacs-bohai/DATS/utf8.dats: 929(line=23, offs=58) -- 
> 934(line=23, offs=63): error(3): unsolved constraint: 
> C3NSTRprop(C3TKmain(); S2Eeqeq(S2Evar(l$8600$8666(14318)); 
> S2Evar(l$8600$8601(14253 
> /home/kiwamu/src/uemacs-bohai/DATS/utf8.dats: 929(line=23, offs=58) -- 
> 934(line=23, offs=63): error(3): unsolved constraint for var 
> preservation 
> typechecking has failed: there are some unsolved constraints: please 
> inspect the above reported error message(s) for information. 
> exit(ATS): uncaught exception: 
> _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
>  
>
> make: *** [Makefile:75: utf8.dats.c] Error 1 
> ``` 
>
> Best regards, 
> -- 
> Kiwamu Okabe at METASEPI DESIGN 
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/7b1a17e9-afde-47de-ba5b-154fbbb2fce9%40googlegroups.com.


Re: GADT question

2018-10-16 Thread Artyom Shalkhakov
Chris,

What if a runtime tag for type is introduced?

datatype rtti (t@ype) =
  | Rbool(bool)
  | Rint(int)

and then in Eq:

  | Eq(bool) of (rtti(a), Expr a, Expr a) 

during evalution there would be some kind of dynamic check on the tag as 
well.

Another idea is to make [eval] evaluate to some kind of type of values. 
This type could be represented by a flat tagged union. Then you could do a 
check on the tag of the union at runtime, and select appropriate function 
to do the equality checking. Essentially what HX proposed, but with a flat 
unboxed type representing the values.

On Tuesday, October 16, 2018 at 4:51:15 AM UTC+3, Chris Double wrote:
>
> I have some GADT code that fails at the C compilation stage. It's a 
> variant of: 
>
> https://gist.github.com/doublec/a3cc8f3431cabe9a319c8e7ba27e7890 
>
> But the Eq constructor of Expr uses the type index instead of being 
> 'int' so equality can be done against booleans and ints. The full code 
> is: 
>
> 8<--- 
> #include "share/atspre_define.hats" 
> #include "share/atspre_staload.hats" 
>
> datatype Expr(a:t@ype)  = 
>   | I(int) of int 
>   | B(bool) of bool 
>   | Add(int) of (Expr int, Expr int) 
>   | Mul(int) of (Expr int, Expr int) 
>   | Eq(bool) of (Expr a, Expr a) 
>
> extern fun{a:t@ype} equals(t1:a, t2:a): bool 
> implement equals(t1,t2) = g0int_eq(t1,t2) 
> implement equals(t1,t2) = eq_bool0_bool0(t1,t2) 
>
> fun{a:t@ype} eval(x:Expr a): a = 
>   case+ x of 
>   | I i => i 
>   | B b => b 
>   | Add (t1, t2) => eval(t1) + eval(t2) 
>   | Mul (t1, t2) => eval(t1) * eval(t2) 
>   | Eq (t1, t2) => equals(t1, t2) 
>
> implement main0() = let 
>   val term1 = Eq(I(5), Add(I(1), I(4))) 
>   val term2 = Mul(I(2), I(4)) 
>   val res1 = eval(term1) 
>   val res2 = eval(term2) 
> in 
>   println!("res1=", res1, " and res2=", res2) 
> end 
> 8<--- 
>
> This fails to compile at the C stage with: 
>
> In file included from arith3_dats.c:15:0: 
> arith3_dats.c: In function ‘eval_2__2__1’: 
> arith3_dats.c:1098:24: error: ‘PMVtmpltcstmat’ undeclared (first use 
> in this function) 
>  ATSINSmove(tmpret2__1, 
> PMVtmpltcstmat[0](equals)(tmp9__1, tmp10__1)) ; 
> ^ 
> ATS2-Postiats-0.3.11//ccomp/runtime/pats_ccomp_instrset.h:276:37: 
> note: in definition of macro ‘ATSINSmove’ 
>  #define ATSINSmove(tmp, val) (tmp = val) 
>  
>
> Any thoughts on what I'm doing wrong? 
>
> -- 
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/3fa603b6-eda2-4f0e-b5ff-b69ff2ed6c27%40googlegroups.com.


Re: ATS3: Parsing

2018-10-11 Thread Artyom Shalkhakov
Hi Hiroshi,

On Thursday, October 11, 2018 at 7:56:53 AM UTC+3, Hiroshi Sakurai wrote:
>
> Why your a line of code is very short?
> Do you write program using Smart phone?
>

That seems like a correct observation. :-) It's narrow enough to fit on my 
phone!
 

>
> 2018年10月11日木曜日 10時32分09秒 UTC+9 gmhwxi:
>>
>> FYI.
>>
>> I am pleased to make an announcement
>> that I have almost finished a parser for ATS3:
>>
>> https://github.com/githwxi/ATS-Xanadu
>>
>> This time, I use a design that stores all the syntax
>> error of a program in the generated abstract syntax
>> tree (AST). To report syntax errors, one needs to implement
>> what I call a "syntax-reader" to traverse the AST. I imagine
>> that different syntax-readers can be written for targeting users
>> of different levels or backgrounds. And I suppose that writing
>> such a syntax-reader is a quick way to learn the concrete syntax
>> for ATS3 :) I will say more about this in ats-lang-devel:
>>
>> https://groups.google.com/forum/#!forum/ats-lang-devel
>>
>> (To join the above group, you need to issue a request)
>>
>> I plan to output ATS3 abstract syntax trees in JSON format. This
>> means that one can implement a syntax reader in languages other
>> than ATS.
>>
>> Cheers!
>>
>>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/c59e3847-e8a9-4c38-ac2e-62a4ab5d85df%40googlegroups.com.


Re: An "I suck at ATS" screencast

2018-09-05 Thread Artyom Shalkhakov
Hi Julian!

ср, 5 сент. 2018 г. в 13:42, Julian Fondren :

> Trying something different with
> https://www.bitchute.com/video/oK0EqH5035cN/ (or
> https://ats-lang.moe/isaats/isaats-008.webm )
>
> Instead of spoken commentary, there's typed commentary, with music.
>
> I think spoken commentary makes for a much better video, but they're also
> videos that are a lot harder *for me* to make.
>
> If any of you have *merely technological *barriers to making videos about
> ATS, please let me know. That part is easy :) In the latest video I don't
> even produce any code extemporaneously, except to make a few edits, and I
> think that format would work fine with spoken commentary.
>
>
I've watched this video in full and it's nice! You took a problem and
presented solutions with their pros and cons.

Since you're recording your terminal, you might settle for very simple
"tele typing" or some such. I guess there was project for doing just that:
recording terminal interaction and then playing it back in the browser.
This should make it simpler for you to host your videos.

How do you make these videos? I'll probably record something as well!


> On Thursday, August 16, 2018 at 2:19:01 AM UTC-5, Julian Fondren wrote:
>>
>> Found here: https://www.bitchute.com/video/arsFOT0Apsw2/
>> <https://www.google.com/url?q=https%3A%2F%2Fwww.bitchute.com%2Fvideo%2FarsFOT0Apsw2%2F=D=1=AFQjCNGr-Ee7SeH_iEZQa9sgaxcDILlg4w>
>>
>> I have some other videos in advance, so I'll try to be regular about
>> uploading them.
>>
>> The first is just 'hello world'. Although the video is 46+ minutes long,
>> it does show a successful 'hello world' in the first minute.
>>
>> The "I suck at ATS" part of the title is
>> 1. fairly appropriate considering the content
>> 2. a small tribute to a Youtuber who'd died shortly before I recorded the
>> video
>> 3. a title I'll use, even if hypothetically I stop sucking at ATS, for
>> any ATS screencsat that's similarly unscripted and unprepared (apart from
>> an idea of something to do and the feeling that I can probably do it over
>> the course of a video)
>>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/e1add075-fb66-491c-9f31-e54c26c9494d%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/e1add075-fb66-491c-9f31-e54c26c9494d%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqgQaSP5de8R0RPcZi8Dsv_TP1nOsoqbCBbXDVguy06tyA%40mail.gmail.com.


Re: An "I suck at ATS" screencast

2018-08-16 Thread Artyom Shalkhakov
Hi Julian!

I have to admit, I too suck at ATS! :-)

Humility helps a great deal!

чт, 16 авг. 2018 г., 13:19 Julian Fondren :

> Found here: https://www.bitchute.com/video/arsFOT0Apsw2/
>
> I have some other videos in advance, so I'll try to be regular about
> uploading them.
>
> The first is just 'hello world'. Although the video is 46+ minutes long,
> it does show a successful 'hello world' in the first minute.
>
> The "I suck at ATS" part of the title is
> 1. fairly appropriate considering the content
> 2. a small tribute to a Youtuber who'd died shortly before I recorded the
> video
> 3. a title I'll use, even if hypothetically I stop sucking at ATS, for any
> ATS screencsat that's similarly unscripted and unprepared (apart from an
> idea of something to do and the feeling that I can probably do it over the
> course of a video)
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/fb20c175-be89-4bb3-8ab6-09a08b550690%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqh5g3YHsj_%2Bn3%3DdQKfGfgdGv20YQZyZKVMHJnc2mnUo8Q%40mail.gmail.com.


Re: Postiats and C errors with array

2018-08-06 Thread Artyom Shalkhakov
вт, 7 авг. 2018 г. в 8:18, Hongwei Xi :

>
> @[int][3] is the type for a flat int array of size 3.
>
> Unfortunately, it is not fully supported at this point
> (it can only be assigned to a var). Please use @(int, int, int)
> instead.
>
>
Are you planning to support this in ATS3?

I guess another way to solve this problem right now is to use $extype for
[row].


> On Mon, Aug 6, 2018 at 7:51 PM, 'Yannick Duchêne' via ats-lang-users <
> ats-lang-users@googlegroups.com> wrote:
>
>> I’m unsure if it’s something wrong with what I wrote (ex. may be it’s not
>> allowed) or with Postiats. The sample below type‑checks, but compilation
>> fails with an INTERROR message.
>>
>> The sample:
>>
>> typedef row = @[int][3]
>> val row1:row = @[int](1, 2, 3)
>> val row2:row = @[int](4, 5, 6)
>> var a = @[row][2](row1, row2)
>> val a12 = a[1].[2]
>>
>> On the second line, it fails with:
>>
>> > INTERROR(pats_ccomp_dynexp): hidexp_ccomp: hde0 =
>> HDEarrinit(HSEapp(HSEcst(atstkind_t0ype);
>> HSEs2exp(S2Eextkind(atstype_int))); HDEint(3); HDEi0nt(1); HDEi0nt(2);
>> HDEi0nt(3))
>>
>>
>> If I try this instead:
>>
>> typedef row = @[int][3]
>> var row1:row = @[int](1, 2, 3)
>> var row2:row = @[int](4, 5, 6)
>> var a = @[row][2](row1, row2)
>> val a12 = a[1].[2]
>>
>> … Postiats can compile it, but I then I have numerous error while
>> compiling C. Many of these errors mentions ATSstatmpdec and there are also
>> C syntax errors.
>>
>> --
>> 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 post to this group, send email to ats-lang-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ats-lang-users/9695cba1-b5c0-463e-9356-60035b1bb142%40googlegroups.com
>> <https://groups.google.com/d/msgid/ats-lang-users/9695cba1-b5c0-463e-9356-60035b1bb142%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpehPjppMhcBfqevkwuKAynk8oEjs9ytaxa0Y6_CPXSww%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpehPjppMhcBfqevkwuKAynk8oEjs9ytaxa0Y6_CPXSww%40mail.gmail.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqj-jNhH7UmEeLRU0sfwLtnuhQzgfKrJLdKKKMUj2CZVCQ%40mail.gmail.com.


Re: Cross-compiling for Windows

2018-08-02 Thread Artyom Shalkhakov
Hi Vanessa,

пт, 3 авг. 2018 г. в 8:59, Vanessa McHale :

> Hi all,
>
> Debian packages a cross-compiler targeting windows,
> gcc-x86_64-w64-mingw32. Unfortunately, atslib fails to build with this,
> due to the following error:
>
>
> In file included from .atspkg/c/prelude/DATS/filebas.c:94:0:
>
> /home/vanessa/.atspkg/0.3.11/lib/ats2-postiats-0.3.11/libats/libc/CATS/sys/types.cats:78:9:
>
> error: unknown type name ‘uid_t’ typedef uid_t
> atslib_libats_libc_uid_type ; ^
>
> /home/vanessa/.atspkg/0.3.11/lib/ats2-postiats-0.3.11/libats/libc/CATS/sys/types.cats:79:9:
>
>
> error: unknown type name ‘gid_t’ typedef gid_t
> atslib_libats_libc_gid_type ; ^ )
>
>
> Is this an upstream problem with the cross-compiler? Or is this
> something I could work around?
>
>
I guess this is POSIX-specific stuff, so no, I don't think you directly map
it to something that Windows understands, unless you fall back to Cygwin.

See also:

https://github.com/githwxi/ATS-Postiats-contrib/issues/30

You could also search for "mingw" in the group to find other discussions as
well.

>
> Thanks,
> Vanessa
>
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/2171b521-923c-a366-0b67-e4a1d791f354%40iohk.io
> .
>


-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqh%2BSh53dJ7YmzVORydhmtbSZv1_vJJd8GwdsLzdTALxXw%40mail.gmail.com.


Re: Blockchain + Smart Contract in ATS - looking for collaborators

2018-05-04 Thread Artyom Shalkhakov
Hi Lance,

On Saturday, May 5, 2018 at 2:40:00 AM UTC+6, Lance Galletti wrote:
>
>
> Hi Artyom,
>
> Thanks for reading! So glad you asked because I actually just finished 
> implementing a (very minimal) query language for creating and querying a 
> database that is backed up on the blockchain. You can read about this here: 
> https://beta.observablehq.com/@galletti94/functional-blockchain-part-2 
> but it is still a very rough draft.
>
>
You're writing it faster than I'm able to read. :-)

I was thinking along these lines, actually. Can we use blockchain for 
painless distributed line-of-business apps? Say I have an app that needs to 
sync data with a central server (the app is MOSTLY offline, and setting up 
proper networking is too costly).
 

> From here, I see this project going two ways and I would love to know what 
> people think will be more useful.
>
> 1. Add distribution to the blockchain so that we have a somewhat complete 
> toy application that people can use in order to test various blockchain 
> related ideas. For example, different consensus algorithms, ways to store 
> the blockchain etc. I am very interested for example in the problem of the 
> size of the blockchain and how that will severely limit its use and I would 
> love to test some of my ideas on this simulator.
>

Scalability is an interesting problem to tackle.

Another issue, again from the business side of things, is whether it would 
make it easier to describe typical business stuff (where you have logical 
facts, and procedural knowledge, and it usually all gets intermixed to the 
point of being totally incomprehensible).

2. Turn this into a template. That way if you would like to build a web 
> interface for example (instead of command line), or if you would like to 
> implement different languages etc you can fork and (hopefully) just 
> copy-paste your code.
>
> I would love to hear your thoughts if you have other suggestions as well!
>
>
> On Thursday, May 3, 2018 at 11:30:13 PM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hi Lance,
>>
>> On Friday, April 27, 2018 at 10:17:01 PM UTC+6, Lance Galletti wrote:
>>>
>>> Hey ATS users!
>>>
>>> I recently had the chance to build a blockchain and smart contract 
>>> language in ATS - all with a nice CLI thanks to 
>>> https://github.com/ashalkhakov/colorado.
>>>
>>> I wrote a small blog post about it here:
>>>
>>> https://beta.observablehq.com/@galletti94/functional-blockchain
>>>
>>> and am looking for collaborators to take this to the next level. If you 
>>> would like to help me out with enhancing the language or CLI, or if you 
>>> have a grand vision / feedback you would like to share, please reach out!
>>>
>>>
>> This is a very good write-up! Looks like now I understand the idea behind 
>> blockchain and smart contracts.
>>
>> I'm wondering what do you plan to do next?
>>
>> Thank you!
>>>
>>> Lance
>>>
>>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/9b3e1b1c-c41a-404c-9db0-1f4f03cedae1%40googlegroups.com.


Re: Nix

2018-05-01 Thread Artyom Shalkhakov
2018-05-02 10:25 GMT+06:00 Steinway Wu <steinway...@gmail.com>:

> Cool! I just learned about Nix recently, and it looks (at first glance, at
> least) promising. Do you (or Brandon)  have any experiences comparing
> packaging individual ATS libraries using NPM vs using Nix?
>
>
I don't much to share here.

We do use Docker at work for some intricate build environments, it's very
nice since everything is compartmentalized and you know exactly what stuff
is for what. Also helps with updates.

Nix is similar in this regard, you get to know your dependencies very well.
But I didn't use it like that, just as a distro for my laptop.

Brandon, would you kindly chime in?

On Tuesday, May 1, 2018 at 11:29:29 PM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hi Steinway,
>>
>> These days Brandon Barker maintains ATS packages for NixOS:
>>
>> https://github.com/NixOS/nixpkgs/blob/master/pkgs/developmen
>> t/compilers/ats2/default.nix
>>
>> You can install ATS2 as follows
>>
>> $ nix-env -i ats2
>>
>> I used to have a separate environment for ATS2 development on my laptop.
>> Nothing fancy, just ATS2, binutils and the like. For me, Docker provides a
>> much simpler approach.
>>
>>
>> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ats-lang-users/576d8977-57a5-4618-ae45-c9b1c1e5fef9%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/576d8977-57a5-4618-ae45-c9b1c1e5fef9%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqg3HtTE8R9v8HSfpkQ9t8hpz_wMttGLsooRxs2U4q0UNQ%40mail.gmail.com.


Re: Nix

2018-05-01 Thread Artyom Shalkhakov
Hi Steinway,

These days Brandon Barker maintains ATS packages for NixOS:

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/ats2/default.nix

You can install ATS2 as follows

$ nix-env -i ats2

I used to have a separate environment for ATS2 development on my laptop.
Nothing fancy, just ATS2, binutils and the like. For me, Docker provides a
much simpler approach.

2018-05-01 9:25 GMT+06:00 Steinway Wu <steinway...@gmail.com>:

> Hi,
>
> I just noticed that there are some Nix scripts. I never knew we have Nix
> efforts. Could someone provide some insights into the experiences using Nix
> for ATS? Is it working? Does someone maintain a Nix package for ATS?
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ats-lang-users/cdb0af26-dc72-4955-9ffe-5591d05022e2%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/cdb0af26-dc72-4955-9ffe-5591d05022e2%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqhFvOZBNCKVVao5XbC2QdO69kz81ZENCixHYpd5%3DrXMuw%40mail.gmail.com.


Re: Functions from datasorts to datasorts

2018-04-09 Thread Artyom Shalkhakov
2018-04-09 11:35 GMT+06:00 Andrew Knapp <andy.j.kn...@gmail.com>:

> Is it possible to write (proof) functions from datasorts to datasorts? For
> example, if we have
>
> datasort tlist =
>   | tnil
>   | tcons(t0ype, tlist)
>
> it would be nice to write something equivalent to
>
> tlist_append : (tlist, tlist) -> tlist
> tlist_filter: (tlist, (tlist) -> bool) -> tlist
>
> that could be applied to a tlist directly. I ask because I was playing
> around with templates, and it turns out you can write templates like
>
> extern fn {t:tlist} foo(): void
> extern fn {a:t0ype} foo$fopr(): void
>
> implement foo() = ()
> implement(a,ts) foo<tcons(a,ts)>() = (foo$fopr(); foo())
>
> that compile and do what you expect.
>

Indeed, this works:

https://glot.io/snippets/ezy53k0uij

(except it hits a well-known bug).

>
>
> It would be nice to implement things like tlist_append in some
> non-template way, because templates force you to transform everything into
> continuation passing style, which hampers composition and is quite verbose.
>
> I have to say that if there were a few built-in functions from types to
> datasorts (e.g. various queries on type definitions, serialize type/record
> field to value-level string, etc.), a convenient way to write functions
> directly between datasorts, and a few more niceties, you could get really,
> really far in terms of metaprogramming.
>
> PS the error messages arising from this datasort-based template
> metaprogramming are already light years ahead of C++, believe it or not :)
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ats-lang-users/2a781501-946c-48d0-8535-a2545ebce689%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/2a781501-946c-48d0-8535-a2545ebce689%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqikV5aD2Sbj%2BCjwE6LFhP8S6ArjEP%3DFJmrJcvHYK_1_TA%40mail.gmail.com.


ATS/C programming: a book

2018-04-06 Thread Artyom Shalkhakov
Hi all,

I wrote this intro here:

https://ashalkhakov.gitbooks.io/ats-c-programming/content/

The idea is to provide a better learning experience for C programmers (and 
maybe C++ programmers).

The plan is to cover these things:

1. handling command line arguments (the argv type in ATS)
2. working with strings (strbuf, etc.-- why so many types for strings in 
ATS)
3. working with global mutable state (static memory allocation, precisely 
what one does in C)
4. separate modules (sats/dats distinction, focussing on what the C 
programmer does instead)
5. working with arrays (also why strbuf is not simply an array, although it 
might be backed by one)
6. working with macros in C and ATS (also why macros are different in ATS), 
with some typical examples (constants, conditional compilation, etc.)
7. file or console I/O
8. printing values to STDOUT (and why ATS doesn't provide the printf 
function)
9. working with mutable pointer-based data structures (lists, trees, etc.)
10. doubly-linked data structures/various difficult-to-tackle aliasing 
scenarios
11. how to handle opt with by-ref parameters / what that means for C 
programmers (pointer-to-pointer etc.)
12. mutable state and branching/cases
13. loops/recursive functions (why use loops instead of functions and vice 
versa)

I just took the K's book about C and re-written their examples in ATS. 
It's really unfinished. Thoughts?

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/28067077-ae75-4f3c-bd61-dbc58af40149%40googlegroups.com.


Re: Intro to ATS - How to code productively

2018-03-31 Thread Artyom Shalkhakov
Hi Lance,

I've put this 
<https://gist.github.com/ashalkhakov/16cf939ba5a7e91cc68733c0441c029b> 
together.

What do you think? And the rest of the group? This is mostly aimed at C 
programmers.

On Thursday, March 29, 2018 at 1:48:45 AM UTC+6, Lance Galletti wrote:
>
> Awesome thank you! Looking forward to it! :)
>
> On Wednesday, March 28, 2018 at 12:00:14 PM UTC-4, Artyom Shalkhakov wrote:
>>
>> On Wednesday, March 28, 2018 at 9:34:37 PM UTC+6, Lance Galletti wrote:
>>>
>>> Hi Artyom!
>>>
>>> Thank you for your feedback! It is great to hear an advanced 
>>> programmer's perspective on the appeal of ATS. If you have the time it 
>>> would be great to incorporate into the write-up a section about this! :)
>>>
>>>
>> I wouldn't call myself an advanced programmer, but I've been interested 
>> in ATS programming for a lot of time, that's true.
>>
>> I'll write a sales-pitch. It's really exciting stuff (to me, at least!).
>>  
>>
>>> So far I have been just putting together what I have learned from 
>>> Hongwei's classes and books but I will definitely be checking out HtDP - 
>>> thank you for the suggestion!
>>>  
>>>
>>
>>> On Wednesday, March 28, 2018 at 3:13:37 AM UTC-4, Artyom Shalkhakov 
>>> wrote:
>>>>
>>>> Hi Lance,
>>>>
>>>> On Tuesday, March 27, 2018 at 9:40:55 PM UTC+6, Lance Galletti wrote:
>>>>>
>>>>> Hi ats users!
>>>>>
>>>>> I recently had the opportunity to give a talk at a hackathon about ATS 
>>>>> and coding productivity / quality. I thought I would share my slides here:
>>>>>
>>>>>
>>>>> https://docs.google.com/presentation/d/157VR0oQNTfUiiChYdbv77PYZkYKo_zkZfwRiqGv6sEY/edit?usp=sharing
>>>>>
>>>>> And the informal write up I am currently developing:
>>>>>
>>>>> https://github.com/galletti94/magnificATS/tree/master/INTRO
>>>>>
>>>>> If, like me, you are passionate about coding quality, methodology, 
>>>>> productivity, or functional programming and, of course ATS, please reach 
>>>>> out!
>>>>>
>>>>>
>>>> First off, I chuckled when I saw the name of the repo. :-)
>>>>
>>>> I want to write something about the C-style programming for ATS, but 
>>>> not quite have the time (or the guts or whatever it is I lack). It would 
>>>> be 
>>>> great to help fellow programmers learn more about ATS!
>>>>  
>>>>
>>>>> I would be happy to collaborate on the write up and hear your thoughts 
>>>>> about what drew YOU to ATS.
>>>>>
>>>>
>>>> I still view ATS as C-with-proper-type-system. :) This is what drew  me 
>>>> to ATS: you can write safe, efficient systems-level programs but this will 
>>>> require some theorem proving, bringing this academic discipline close to 
>>>> actual programming practice (or you can cast your way through the types, 
>>>> but then you're the one to blame if things go wrong). ATS helped me to 
>>>> improve my knowledge of C.
>>>>
>>>> Regarding your write-up, have you seen HtDP (How to Design Programs)? 
>>>> Their "design recipes" are somewhat similar IIRC (proceed top-down, 
>>>> refine, 
>>>> state pre- and post-conditions, provide examples of evaluation aka tests).
>>>>
>>>> Looking forward to connecting!
>>>>>
>>>>> Lance Galletti
>>>>> gall...@bu.edu
>>>>>
>>>>>
>>>>>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/be6003ab-8234-4872-9489-ac410f5b387d%40googlegroups.com.


Re: Intro to ATS - How to code productively

2018-03-28 Thread Artyom Shalkhakov
On Wednesday, March 28, 2018 at 9:34:37 PM UTC+6, Lance Galletti wrote:
>
> Hi Artyom!
>
> Thank you for your feedback! It is great to hear an advanced programmer's 
> perspective on the appeal of ATS. If you have the time it would be great to 
> incorporate into the write-up a section about this! :)
>
>
I wouldn't call myself an advanced programmer, but I've been interested in 
ATS programming for a lot of time, that's true.

I'll write a sales-pitch. It's really exciting stuff (to me, at least!).
 

> So far I have been just putting together what I have learned from 
> Hongwei's classes and books but I will definitely be checking out HtDP - 
> thank you for the suggestion!
>  
>

> On Wednesday, March 28, 2018 at 3:13:37 AM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hi Lance,
>>
>> On Tuesday, March 27, 2018 at 9:40:55 PM UTC+6, Lance Galletti wrote:
>>>
>>> Hi ats users!
>>>
>>> I recently had the opportunity to give a talk at a hackathon about ATS 
>>> and coding productivity / quality. I thought I would share my slides here:
>>>
>>>
>>> https://docs.google.com/presentation/d/157VR0oQNTfUiiChYdbv77PYZkYKo_zkZfwRiqGv6sEY/edit?usp=sharing
>>>
>>> And the informal write up I am currently developing:
>>>
>>> https://github.com/galletti94/magnificATS/tree/master/INTRO
>>>
>>> If, like me, you are passionate about coding quality, methodology, 
>>> productivity, or functional programming and, of course ATS, please reach 
>>> out!
>>>
>>>
>> First off, I chuckled when I saw the name of the repo. :-)
>>
>> I want to write something about the C-style programming for ATS, but not 
>> quite have the time (or the guts or whatever it is I lack). It would be 
>> great to help fellow programmers learn more about ATS!
>>  
>>
>>> I would be happy to collaborate on the write up and hear your thoughts 
>>> about what drew YOU to ATS.
>>>
>>
>> I still view ATS as C-with-proper-type-system. :) This is what drew  me 
>> to ATS: you can write safe, efficient systems-level programs but this will 
>> require some theorem proving, bringing this academic discipline close to 
>> actual programming practice (or you can cast your way through the types, 
>> but then you're the one to blame if things go wrong). ATS helped me to 
>> improve my knowledge of C.
>>
>> Regarding your write-up, have you seen HtDP (How to Design Programs)? 
>> Their "design recipes" are somewhat similar IIRC (proceed top-down, refine, 
>> state pre- and post-conditions, provide examples of evaluation aka tests).
>>
>> Looking forward to connecting!
>>>
>>> Lance Galletti
>>> gall...@bu.edu
>>>
>>>
>>>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/cb56f1f9-09a9-41eb-ab87-5b9bf1eb6bea%40googlegroups.com.


Re: Example code for traits/mixins/multiple inheritance

2018-03-28 Thread Artyom Shalkhakov
Hi Brandon,

On Saturday, March 10, 2018 at 3:50:19 AM UTC+6, Brandon Barker wrote:
>
> There is a small part of a project 
>  I'd like to convert 
> to ATS where linear types could be helpful in tracking cancellation of 
> running tasks (and other things I'm probably forgetting just now, but are 
> on the issue tracker). The part 
> 
>  
> I'm interested in tackling here implements referentially transparent 
> methods on reactive variables. I'm sure I can find a way to do this without 
> traits (mixins) but want to maintain as direct a port as possible. I have a 
> feeling the answer may involve templates.
>
> The other part of the project would be cool too, but it kind of depends on 
> xml literals being a thing (or later, XML interpolation): using scala.js to 
> write web pages that depend on these reactive variables. It is quite a fun 
> little framework.
>

Seems like a lot of fun! How does it work? I was at some point thinking of 
faking HTML/XML literals in ATS using a preprocessor 

...

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/4ab44d66-a03c-4326-b62c-0299c0527a1d%40googlegroups.com.


Re: ATSPackage: a build tool/package manager for ATS

2018-02-20 Thread Artyom Shalkhakov
Hi,

On Sunday, February 18, 2018 at 12:50:54 PM UTC+6, vamc...@gmail.com wrote:
>
> Hi all,
>
> I have been working on atspkg  for 
> some time now, and it finally has a stable configuration format, so I 
> figured the wider ATS community could benefit.
>
> It's definitely not a full-fledged package manager on the order of cabal, 
> but it already greatly simplifies the process of building libraries or 
> binaries in ATS, particularly for those without a background in systems 
> programming.
>
> In the meantime, the docs need some improvement, so feel free to ask any 
> questions or open an issue in the repo if you find something deficient. 
> polyglot  has a reasonably nice 
> example of how to use it to make binaries. 
>
>
Thanks much!

Will try it out the next time I do ATS programming.
 

> Best,
>
> V. E. McHale
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/88c7cfc5-a986-40a0-be06-c62298721eb9%40googlegroups.com.


Re: ATS3: ATS/Xanadu

2018-02-20 Thread Artyom Shalkhakov
On Saturday, February 10, 2018 at 12:15:22 AM UTC+6, gmhwxi wrote:
>
> For the moment, I just want to open a thread for ATS3.
>
> I decided to pick ATS/Xanadu for the full project name. I like the name 
> Xanadu
> because it is poetic and brings a feel of exoticness.
>  
>
ATS3 is supposed to be compiled to ATS2. At least at the beginning. I will 
> try to
> write more about what I have in mind regarding ATS3.
>
> I know that a lot of people have been complaining about the syntax of 
> ATS2. So
> we can start the effort of designing some "nice" syntax for ATS3. Please 
> feel free
> to post here if you would like share your opinions and ideas.
>
>
I will say what I would like to see:

1. IDE support (especially for the hard parts, i.e. the proofs!)
2. the syntax is very complex (maybe simplify?)
3. better support for flat types (e.g. flat unions, flat unboxed arrays on 
stack, etc.)
4. compilation to wasm
5. tools (especially for building, but also package management)
6. some kind of help for implementing various intricately-linked data 
structures (doubly-linked lists, doubly-linked trees, etc.)
7. improvements to templates (e.g. templates for indexed type variables, is 
that even possible?)
 
To make ATS viable, we have to make its kind of typeful programming 
friendly.

I will be happy to take the lead but we definitely need to have some form 
> of community
> effort on this project given its size and scope.
>
> Cheers!
>
> --Hongwei
>
> PS: I felt rushed every time up to now when implementing ATS. This time I 
> am hoping
> to have the luxury of thinking about implementation a bit before actually 
> doing it :)
>
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/eaafa947-433d-4252-b915-41b2df384f03%40googlegroups.com.


Re: ATS3: ATS/Xanadu

2018-02-13 Thread Artyom Shalkhakov
If we talk syntax, why not adopt that of C? :-)

13 февр. 2018 г. 8:43 ПП пользователь "August Alm" 
написал:

I second the preference for Haskell-style "let" and "where", which is to
say no "end"s and no curly braces.
Of course, this requires indentation to be syntactic and not just a matter
of aesthetics/readability. I think this
is a good thing, not just because it is more concise but maybe even more so
because it enforces readability
(non-indented code will not compile) and stylistic uniformity in the
community.

As a side-note, Haskell allows curly braces and semi-colons as an optional
form of writing.
One may write "foo f = let {x=a; y=b; ...} in ...", etc. Useful for
one-liners or for people who want their code
to look like more C-ish.


Den måndag 12 februari 2018 kl. 19:59:54 UTC+1 skrev gmhwxi:
>
> Thanks.
>
> Haskell and Idris are definitely on my radar.
>
> Type inference in ATS is very week (largely due to the support
> for dependent types and linear types). To support concise syntax,
> type inference in ATS needs to greatly strengthened.
>
> On Sunday, February 11, 2018 at 8:34:48 PM UTC-5, vamchale wrote:
>>
>> I don't have any concrete suggestions, but I would suggest Idris as an
>> example to follow. Haskell syntax is relatively popular and concise, and
>> Idris' is even more refined.
>>
>> I will say I'd prefer syntax that eases functional programming, but that
>> might just be me. And I think that replacing - with something
>> more concise like -o would be a good decision either way.
>>
>> On Friday, February 9, 2018 at 12:15:22 PM UTC-6, gmhwxi wrote:
>>>
>>> For the moment, I just want to open a thread for ATS3.
>>>
>>> I decided to pick ATS/Xanadu for the full project name. I like the name
>>> Xanadu
>>> because it is poetic and brings a feel of exoticness.
>>>
>>> ATS3 is supposed to be compiled to ATS2. At least at the beginning. I
>>> will try to
>>> write more about what I have in mind regarding ATS3.
>>>
>>> I know that a lot of people have been complaining about the syntax of
>>> ATS2. So
>>> we can start the effort of designing some "nice" syntax for ATS3. Please
>>> feel free
>>> to post here if you would like share your opinions and ideas.
>>>
>>> I will be happy to take the lead but we definitely need to have some
>>> form of community
>>> effort on this project given its size and scope.
>>>
>>> Cheers!
>>>
>>> --Hongwei
>>>
>>> PS: I felt rushed every time up to now when implementing ATS. This time
>>> I am hoping
>>> to have the luxury of thinking about implementation a bit before
>>> actually doing it :)
>>>
>>> --
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/7bf25292-2094-4d32-9d74-6937e298a240%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3DqitoDCyXydY2ZsnwKtT8RP%2B51mkjNsYt5gyf_YUEN1u3A%40mail.gmail.com.


Re: libatscc2js-rt: npm package for the libatscc2js runtime

2017-10-29 Thread Artyom Shalkhakov
On Sunday, October 29, 2017 at 4:28:58 AM UTC+6, gmhwxi wrote:
>
>
> I added a short README in the following directory:
>
>
> https://github.com/githwxi/ATS-Postiats/tree/master/contrib/libatscc2js/ATS2-0.3.2
>
> Basically, all you need to do is to execute 'make all all_in_one'. Then 
> take
> a look at the 'output' directory.
>
>
I'll add a package.json into that directory and then submit a PR to you, if 
you don't mind.
 

>
>
> On Sat, Oct 28, 2017 at 11:25 AM, Artyom Shalkhakov <artyom.s...@gmail.com 
> > wrote:
>
>> How did you build those files? I'll add it to CI if I can. And will also 
>> put the license there as well.
>>
>> 28 окт. 2017 г. 8:55 PM пользователь "Hongwei Xi" <gmh...@gmail.com 
>> > написал:
>>
>>
>> Thanks!
>>
>> You could use MIT/BSD-2 license or BSD-3 (BSD-2 + no endorsement).
>>
>> By the way, everything (so far) in ATS-Postiats/contrib is under MIT 
>> license.
>>
>>
>> On Sat, Oct 28, 2017 at 10:15 AM, Artyom Shalkhakov <
>> artyom.s...@gmail.com > wrote:
>>
>>> Hello all,
>>>
>>> I've published this package here:
>>>
>>> https://www.npmjs.com/package/libatscc2js-rt
>>>
>>> At first I was simply linking to the official files distributed on the 
>>> website, but it really doesn't work very good if you are on a flaky 
>>> Internet connection.
>>>
>>> Now, if you have a project that uses *atscc2js*, then you can just do:
>>>
>>> $ npm i libatscc2js-rt
>>>
>>> and you'll have some files present in this subdirectory:
>>>
>>> node_modules/libatscc2js-rt/src
>>>
>>> I wonder what its license should be? For now I use GPL v3. Maybe we'd 
>>> better generate the package automatically via some CI service in the future.
>>>
>>> -- 
>>> 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 post to this group, send email to ats-lan...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/ats-lang-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ats-lang-users/5bdd173e-5558-48e4-ac6c-9591a4f86ca1%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ats-lang-users/5bdd173e-5558-48e4-ac6c-9591a4f86ca1%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lan...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrTN4evHL%2BAMWJW7VMhZqT_qt_xht%3D1tLBKXaphtgA50Q%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrTN4evHL%2BAMWJW7VMhZqT_qt_xht%3D1tLBKXaphtgA50Q%40mail.gmail.com?utm_medium=email_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 post to this group, send email to ats-lan...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqgm9cTE83bLRrKtO-6vY%2B8xYogQTcRmq1C_P-yXOEC82g%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqgm9cTE83bLRrKtO-6vY%2B8xYogQTcRmq1C_P-yXOEC82g%40mail.gmail.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/5e9f1725-2b13-455c-9077-907101e63d01%40googlegroups.com.


Re: libatscc2js-rt: npm package for the libatscc2js runtime

2017-10-28 Thread Artyom Shalkhakov
How did you build those files? I'll add it to CI if I can. And will also
put the license there as well.

28 окт. 2017 г. 8:55 PM пользователь "Hongwei Xi" <gmh...@gmail.com>
написал:


Thanks!

You could use MIT/BSD-2 license or BSD-3 (BSD-2 + no endorsement).

By the way, everything (so far) in ATS-Postiats/contrib is under MIT
license.


On Sat, Oct 28, 2017 at 10:15 AM, Artyom Shalkhakov <
artyom.shalkha...@gmail.com> wrote:

> Hello all,
>
> I've published this package here:
>
> https://www.npmjs.com/package/libatscc2js-rt
>
> At first I was simply linking to the official files distributed on the
> website, but it really doesn't work very good if you are on a flaky
> Internet connection.
>
> Now, if you have a project that uses *atscc2js*, then you can just do:
>
> $ npm i libatscc2js-rt
>
> and you'll have some files present in this subdirectory:
>
> node_modules/libatscc2js-rt/src
>
> I wonder what its license should be? For now I use GPL v3. Maybe we'd
> better generate the package automatically via some CI service in the future.
>
> --
> 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 post to this group, send email to ats-lang-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/ats-lang-users/5bdd173e-5558-48e4-ac6c-9591a4f86ca1%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/5bdd173e-5558-48e4-ac6c-9591a4f86ca1%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAPPSPLrTN4evHL%2BAMWJW7VMhZqT_qt_xht%
3D1tLBKXaphtgA50Q%40mail.gmail.com
<https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrTN4evHL%2BAMWJW7VMhZqT_qt_xht%3D1tLBKXaphtgA50Q%40mail.gmail.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAKO6%3Dqgm9cTE83bLRrKtO-6vY%2B8xYogQTcRmq1C_P-yXOEC82g%40mail.gmail.com.


Re: ATStead: in-browser structured editing in ATS

2017-10-19 Thread Artyom Shalkhakov
On Friday, October 20, 2017 at 1:08:40 AM UTC+6, gmhwxi wrote:
>
>
> Do you think we could combine ATStead with the following interpreter I 
> wrote:
>
>
> http://www.cs.bu.edu/~hwxi/academic/courses/CS520/Fall16/.xshare/BitBucket/cs520-2016-fall/lectures/lecture-11-28/FPL-lambda/JS/FPL-lambda.html
>
> If I define a datatype, can such an editor be generated based on the 
> datatype
> description?
>

There is no code generation. By the way, would you recommend making [tree] 
parameterized by the type of label? Seems like an obvious thing to do.

Could you point me to the datatype that you use for that language? The 
current object language in ATStead has "lam" an "app" constructs, but not 
"fix" or "ifnz".

On Thursday, October 19, 2017 at 12:09:59 PM UTC-4, Artyom Shalkhakov wrote:
>>
>> Hello all,
>>
>> I'd like to share ATStead:
>>
>> https://rawgit.com/ashalkhakov/ATStead/master/src/index.html
>>
>> It is a simple structured editor based on:
>>
>> http://www.cs.ox.ac.uk/bernard.sufrin/edit.pdf
>>
>> Try it to see if you can enter some expressions! Structured editors are 
>> known to be clunky, but this one is at least modeless. :-)
>>
>> Basically, all functionality presented in the paper works. In contrast to 
>> the paper, the editor's main datastructure is imperative and is very 
>> efficiently updated. So I guess it should scale to big, complex real-world 
>> ASTs (well, one can dream right???).
>>
>> What I'm going to do next:
>>
>>- improve rendering (it's very dumb at the moment, both in terms of 
>>being from-scratch everytime, and in terms of lacking in visual clarity)
>>- improve keyboard entry (handle keybindings, try guessing node types 
>>by lexing the input etc.)
>>- add selection by mouse (this one is simple)
>>- add undo/redo
>>- extend to handle ABTs (so that the editor can help you out with 
>>typical programming stuff: renaming variables, looking up definitions, 
>> etc.)
>>- make easily embeddable in a typical JS application
>>
>>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/0c089ac9-3b81-4205-9920-094645bcf78d%40googlegroups.com.


Re: ATS mode indentation

2017-10-13 Thread Artyom Shalkhakov
This is awesome! I'll try it on the weekend. Thank you!

14 окт. 2017 г. 1:24 AM пользователь "Andrew Knapp" 
написал:

Both of those test cases should work now, as well as a lot of others. Some
of the weird starting errors have been fixed, especially at the top level,
but it won't be possible in the general case.
Supposing you've typed

let
  val foo = 3


there is no way for the indentation engine to know whether you will next
type

let
  val foo = 3
  val bar = 4

or

let
  val foo = 3
 +baz()

The best we can hope for is indentation that is correct after the fact.

Here's the output of running indent-region on the following code. More test
cases are welcome :)

#include "share/atspre_staload.hats"
#include "share/atspre_define.hats"

extern fun imul2
  {i,j:int}(i:int i,j:int j):<>
  [ij:int] (MUL(i,j,ij)|int ij) = "mac#imul2"

extern fun atoi(!strptr): int = "mac#atoi"

fun test(a:int): int = a+1

typedef qwerty = int
typedef dvorak = double

dataprop FACTORIAL(n:int,r:int) =
  | FACTORIAL_BAS(0,1) of ()
  | {n:nat}{r,r1:int} FACTORIAL_IND(n,r) of
(FACTORIAL(n-1,r1), MUL(n,r1,r))

fun factorial
  {n:nat} .<>. (n:int(n)):<>
  [r:int] (FACTORIAL(n,r) | int(r)) =
let
  fun loop
  {i:nat|i <= n}
  {r:int}
  ..
  (
pf: FACTORIAL(i,r) |
n:int n, i: int i, r: int r
  ):<>
  [r:int] (FACTORIAL(n,r) | int r) =
  if n-i>0 then
  let
val (pfmul | r1) = imul2(i+1,r)
  in
loop(FACTORIAL_IND(pf,pfmul) | n, i+1, r1)
  end
  else (pf | r)
in
  loop(FACTORIAL_BAS() | n, 0, 1)
end

fun foo(): int =
let
  fun bar(): int =
  let
fun baz(): int =
let
  val x = 3
  val y = 4
in
  if x > 3 then
x
  else
y
end
  in
baz()
  end
in
  bar()
end

implement main0() = let
  val x = 3
  val (pf | res) = factorial(5)
in
  print_list($list{int}(1,2,3,4,5));
  println!(5);
  println!(res);
end

dataprop food =
  | MILK of ()
  | EGGS of ()

sortdef x = {i:int | i >= 0}
sortdef y = {i:int | i mod 2 == 0}

fun bar(a:int):int =
let
  val x = 3
  val y = 4
  val z = 7
in
  x*y+z
end

fun foo(): int =
let
  val x = 3
  val y = 4
  fun loop(a:int):int =
  let
val y = 4
val z = 7
  in
x+3
  end
in
  if x > 3 then 5 else 8
end



On Thursday, October 12, 2017 at 1:31:18 PM UTC-7, aditya siram wrote:
>
> Huge thanks for working on this. It's difficult and tedious but sorely
> needed.
>
> Here's some bad indentation cases I found:
>   sortdef even = { i:int | i mod 2 == 0  }
>sortdef agz = {l:addr | l > null}
>
>
> implement main0 () =
>   let
> ...
>   in
> ...
>   end
>
>
> On Thursday, October 12, 2017 at 12:47:24 PM UTC-5, Andrew Knapp wrote:
>>
>> Taking a closer look, there are definitely cases I didn't use that behave
>> strangely. As I see it, there are four causes for this.
>>
>> The first is an incomplete treatment of similar constructs that should be
>> indented the same way, e.g. datatype, dataprop, dataviewtype... I thought I
>> had gotten this working, but I didn't test every keyword.
>>
>> The second is things that indent strangely at first, but indent correctly
>> after entering calling newline-and-indent. This behavior is mildly
>> annoying, but it is also inherited from the original SML mode and can be
>> fixed with semicolon usage. I'm not sure SMIE is powerful enough to
>> eradicate this behavior.
>>
>> The third is flat out bugs. For example, different styles of datatype
>> declaration break indentation (i.e. | Foo of (a,b) vs | Foo() of (a,b)).
>>
>> The fourth is my preferred indentation style, which uses much longer
>> lines than yours. I find it painful to read such short lines of code, and
>> so I didn't test that case very much. For example, I would write
>>
>> fun {n:nat} factorial(n:int(n)): [r:int] (FACTORIAL(n,r) | int(r))
>>
>> Do you have any particular examples that stood out as being incorrect? I
>> will continue working on this for my own use, at least :)
>>
>> On Thursday, October 12, 2017 at 5:58:02 AM UTC-7, gmhwxi wrote:
>>>
>>> I gave it a try last night. I encountered many cases of excessive
>>> indentation.
>>>
>>> The syntax of ATS is rich and complex. So it makes sense to require the
>>> programmer
>>> to manually add indentation. With the current ats-mode, you get two
>>> spaces if you hit the
>>> tab key. So you are pretty much in control of indentation. As far as I
>>> know, a lot of programmers
>>> want this kind of control :)
>>>
>>>
>>> On Wed, Oct 11, 2017 at 3:43 PM, Andrew Knapp 
>>> wrote:
>>>
 Hello all,

 By cannibalizing sml.el, I have largely gotten automatic indentation
 working in ATS.

 After a few months of sporadic use, the only problem I couldn't fix is
 excessive indentation after a function has ended.
 This can be fixed by terminating all functions with semicolons, which
 is ugly, but it seems to work.
 If you don't do 

Simple linear objects in ATSCC2JS

2017-10-04 Thread Artyom Shalkhakov
Hello all,

Here's an example of a simple linear object in ATS:

https://github.com/ats-lang/ats-lang.github.io/blob/master/DOCUMENT/INT2PROGINATS/CODE/CHAP_ABSVTYPE/timer.dats

Can this be adapted to work in ATSCC2JS?

This code:

https://gist.github.com/ashalkhakov/85902ec8992acef7eef3fbf0a1c41ddb

Gives the error:

Hello from atscc2js!
ParsingErrors:
/tmp/patsopt_ccats_CEmWFB: 31627(line=872, offs=1) -- 31646(line=872, offs=
20): error(parsing): the syntactic entity [instr] is needed.
/tmp/patsopt_ccats_CEmWFB: 31865(line=882, offs=1) -- 31876(line=882, offs=
12): error(parsing): the syntactic entity [instr] is needed.
/tmp/patsopt_ccats_CEmWFB: 31865(line=882, offs=1) -- 31876(line=882, offs=
12): error(parsing): the syntactic entity [ATSfunbody_end] is needed.
/tmp/patsopt_ccats_CEmWFB: 31032(line=846, offs=1) -- 31046(line=846, offs=
15): error(parsing): the keyword [}] is needed.
/tmp/patsopt_ccats_CEmWFB: 30871(line=838, offs=1) -- 30880(line=838, offs=
10): 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)

Some language feature isn't implemented in ATSCC2JS? If yes, I'd be willing 
to make a PR for it, as long as a hint is given on how to fix it. :-)

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/4f7e50fa-3698-4107-86ec-b13ab26c1db9%40googlegroups.com.


Re: implement template based function on dependent type

2017-10-02 Thread Artyom Shalkhakov
On Monday, October 2, 2017 at 7:41:46 PM UTC+6, gmhwxi wrote:
>
> >>Could you please implement this feature?
>
> I don't really know how.
>
> Embeddable templates were added to ATS2 in an add hoc manner.
> Unlike dependent types or linear types, I had no time studying this
> feature carefully and took a big gamble to just add it.
>

Why I'm asking this is because I wrote a lot of templated code that would 
be much easier to implement with the feature (I guess :-)).

See e.g.:

https://github.com/ashalkhakov/cfgtools/blob/master/src/DATS/grmfuncs.dats#L722

A type is defined on the spot to help with instantiation of templates.
 

>
> On Monday, October 2, 2017 at 3:04:00 AM UTC-4, Artyom Shalkhakov wrote:
>>
>> On Sunday, October 1, 2017 at 7:11:19 PM UTC+6, gmhwxi wrote:
>>>
>>> I wrote something like this:
>>>
>>> extern
>>> fun
>>> {a:t@ype}
>>> minus(x: a, y: a): a
>>> extern
>>> fun
>>> {a:t@ype}
>>> list_minus
>>> {n:int}
>>> (xs : list(a,n), ys : list(a,n)): list(a,n)
>>>
>>> implement
>>> (a,n)
>>> minus<list(a,n)>(xs, ys) = list_minus(xs, ys)
>>>
>>> But this is not actually supported in ATS. A template parameter needs
>>> to be formed using only types.
>>>
>>
>> Could you please implement this feature?
>>
>> This would make it much easier to state more preconditions on the 
>> template functions. As it currently stands, this requires a lot of unsafe 
>> casting to make things work. So modularity comes at expense of safety.
>>  
>>
>>>
>>> Here is something that may be interesting to you:
>>>
>>>
>>> https://groups.google.com/forum/#!searchin/ats-lang-users/runtime$20polymorphism%7Csort:relevance/ats-lang-users/4p37nbLeNm8/9dfUSDCtrlAJ
>>>
>>> On Sun, Oct 1, 2017 at 3:33 AM, Russoul <russ...@gmail.com> wrote:
>>>
>>>> Say, I have a function:
>>>>
>>>> extern fun{a:t@ype}
>>>> minus(x : a, y : a) : a
>>>>
>>>>
>>>> And :
>>>>
>>>> extern fun{a:t@ype}
>>>> list_minus
>>>> {n:nat}
>>>> (xs : list(a,n), ys : list(a,n)) :
>>>> list(a,n)
>>>>
>>>> How can I implement [minus] for list(a,n) ?
>>>>
>>>> I have it this far:
>>>>
>>>> implement(a) minus<List0(a)>(x,y) = list_minus(x,y)
>>>>
>>>> But that does not guarantee that [x] and [y] have the same [n:nat] :
>>>>
>>>> unsolved constraint: C3NSTRprop(C3TKmain(); 
>>>> S2Eeqeq(S2Evar(n$3372$8590(14716)); S2Evar(n$3371$8589(14715
>>>>
>>>>
>>>> -- 
>>>> 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 post to this group, send email to ats-lan...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/ats-lang-users.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/ats-lang-users/19e2dfbd-fe6b-4f41-a520-76a834d8e44a%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/19e2dfbd-fe6b-4f41-a520-76a834d8e44a%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/feeb4578-4369-4208-b628-a9212ad5bde1%40googlegroups.com.


Re: implement template based function on dependent type

2017-10-02 Thread Artyom Shalkhakov
On Sunday, October 1, 2017 at 7:11:19 PM UTC+6, gmhwxi wrote:
>
> I wrote something like this:
>
> extern
> fun
> {a:t@ype}
> minus(x: a, y: a): a
> extern
> fun
> {a:t@ype}
> list_minus
> {n:int}
> (xs : list(a,n), ys : list(a,n)): list(a,n)
>
> implement
> (a,n)
> minus(xs, ys) = list_minus(xs, ys)
>
> But this is not actually supported in ATS. A template parameter needs
> to be formed using only types.
>

Could you please implement this feature?

This would make it much easier to state more preconditions on the template 
functions. As it currently stands, this requires a lot of unsafe casting to 
make things work. So modularity comes at expense of safety.
 

>
> Here is something that may be interesting to you:
>
>
> https://groups.google.com/forum/#!searchin/ats-lang-users/runtime$20polymorphism%7Csort:relevance/ats-lang-users/4p37nbLeNm8/9dfUSDCtrlAJ
>
> On Sun, Oct 1, 2017 at 3:33 AM, Russoul  
> wrote:
>
>> Say, I have a function:
>>
>> extern fun{a:t@ype}
>> minus(x : a, y : a) : a
>>
>>
>> And :
>>
>> extern fun{a:t@ype}
>> list_minus
>> {n:nat}
>> (xs : list(a,n), ys : list(a,n)) :
>> list(a,n)
>>
>> How can I implement [minus] for list(a,n) ?
>>
>> I have it this far:
>>
>> implement(a) minus(x,y) = list_minus(x,y)
>>
>> But that does not guarantee that [x] and [y] have the same [n:nat] :
>>
>> unsolved constraint: C3NSTRprop(C3TKmain(); 
>> S2Eeqeq(S2Evar(n$3372$8590(14716)); S2Evar(n$3371$8589(14715
>>
>>
>> -- 
>> 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 post to this group, send email to ats-lan...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/ats-lang-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/19e2dfbd-fe6b-4f41-a520-76a834d8e44a%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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/75f1973e-b995-49e3-bee4-9c7d26d7001d%40googlegroups.com.


Babelfish (AST parsing)

2017-06-20 Thread Artyom Shalkhakov
Hello all,

Today I've stumbled upon this project:

https://www.gitbook.com/book/bblfsh/documentation/details

And we could create a driver targeted to ATS parsing by using their SDK:

https://doc.bblf.sh/driver/sdk.html

I guess this can be a worthwhile project.

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/c601f60e-2be4-40f7-ab12-8d817167ecf4%40googlegroups.com.


Re: language-ats: ATS Support for Atom Text Editor

2017-06-13 Thread Artyom Shalkhakov
Hi Spencer,

On Sunday, June 11, 2017 at 2:32:25 AM UTC+6, Spencer Hayes wrote:
>
> Hello Everyone,
>
> In case there are any of you who use Atom, I have released a preliminary 
> version of an ATS language pack for Atom titled "language-ats". You can 
> find more information about it on its Atom page 
>  or by viewing the GitHub repo 
> . Installation is detailed 
> in the README where you can also find a link to a video showing the 
> installation process and example. 
>
> There are still many more features that I am looking to add in the future, 
> and if you're familiar with it I am also looking to add more Snippet 
> support as well. If you have any issues with the package or have any 
> suggestions, please let me know 
> ! 
>

Great, thank you! I'll take a look!
 

>
> Thank You,
> Spencer Hayes
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/64272964-3193-48ce-bee6-0af8902594b6%40googlegroups.com.


Re: Handling command line arguments?

2017-05-16 Thread Artyom Shalkhakov
On Monday, May 15, 2017 at 11:00:50 PM UTC+6, gmhwxi wrote:
>
>
> Libats/ML mostly consists of convenience wrappers for
> functions defined in prelude and libats.
>
> If performance is a non-issue, I would prefer to use libats/ML
> as it can save me a lot of coding time.
>
>
I wrote a getopt-style, retro 80's library:

https://github.com/ashalkhakov/atscntrb-as-getopt

Doesn't get more hip than that, I suppose. :-)

This one is written primarily to deal with environments where GC is to be 
avoided (I'm going to use it for ats3d). I also wanted to push forward the 
ATS-as-a-better-C/C++ idea.
 

> On Sunday, May 14, 2017 at 5:16:08 AM UTC-4, Artyom Shalkhakov wrote:
>>
>>
>>
>> On Saturday, May 13, 2017 at 6:38:59 PM UTC+6, gmhwxi wrote:
>>>
>>>
>>> Now, this package is functioning.
>>>
>>> Please see the test01 example in TEST for a typical case
>>> of using it.
>>>
>>> The package is template-based. One can adapt it by re-implementing
>>> some of the templates.
>>>
>>> Maybe someone could write a bit of documentation on the package, but...
>>>
>>> In any case, I wrote it in a way that should minimize the need for
>>> documentation, which I see as a true luxury in software development that
>>> we could not really afford.
>>>
>>> Ideally, code should document itself :) Templates in ATS can offer great
>>> help in this regard.
>>>
>>>
>> Thank you! I will take a look as soon as time permits.
>>
>> I see that you use libats/ML a lot in this library. I'm not familiar with 
>> it, will need some time to explore it.
>>
>> Cheers!
>>>
>>> On Wednesday, May 10, 2017 at 9:32:01 PM UTC-4, gmhwxi wrote:
>>>>
>>>>
>>>> I have just got started working on it. In case you'd like to see
>>>> the progress:
>>>>
>>>>
>>>> https://github.com/githwxi/ATS-Postiats/tree/master/contrib/atscntrb-hx-getargs
>>>>
>>>> I set things up in a way that allows the code to work inside ATS and 
>>>> also work as
>>>> a stand-alone package.
>>>>
>>>> On Wednesday, May 10, 2017 at 8:59:22 AM UTC-4, gmhwxi wrote:
>>>>>
>>>>> Good point!
>>>>>
>>>>> I have some ideas about this. I will make a package shortly.
>>>>>
>>>>> On Wed, May 10, 2017 at 1:00 AM, Artyom Shalkhakov  wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> Is there a ready-made library for handling command line parameters?
>>>>>>
>>>>>> So far I found the following:
>>>>>>
>>>>>>
>>>>>> https://github.com/githwxi/ATS-Postiats/blob/master/utils/jsonlst2arr/jsonlst2arr.dats
>>>>>>
>>>>>> Which sets up an example of what HX thinks should be done to deal 
>>>>>> with command-line arguments. Would somebody like to move it into a 
>>>>>> library?
>>>>>>
>>>>>> -- 
>>>>>> 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 post to this group, send email to ats-lan...@googlegroups.com.
>>>>>> Visit this group at https://groups.google.com/group/ats-lang-users.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/ats-lang-users/3f70c312-504e-417c-8ee4-282cf0e22b41%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/ats-lang-users/3f70c312-504e-417c-8ee4-282cf0e22b41%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/9768e92c-0731-4052-8a89-89bd6be19736%40googlegroups.com.


Re: Handling command line arguments?

2017-05-14 Thread Artyom Shalkhakov


On Saturday, May 13, 2017 at 6:38:59 PM UTC+6, gmhwxi wrote:
>
>
> Now, this package is functioning.
>
> Please see the test01 example in TEST for a typical case
> of using it.
>
> The package is template-based. One can adapt it by re-implementing
> some of the templates.
>
> Maybe someone could write a bit of documentation on the package, but...
>
> In any case, I wrote it in a way that should minimize the need for
> documentation, which I see as a true luxury in software development that
> we could not really afford.
>
> Ideally, code should document itself :) Templates in ATS can offer great
> help in this regard.
>
>
Thank you! I will take a look as soon as time permits.

I see that you use libats/ML a lot in this library. I'm not familiar with 
it, will need some time to explore it.

Cheers!
>
> On Wednesday, May 10, 2017 at 9:32:01 PM UTC-4, gmhwxi wrote:
>>
>>
>> I have just got started working on it. In case you'd like to see
>> the progress:
>>
>>
>> https://github.com/githwxi/ATS-Postiats/tree/master/contrib/atscntrb-hx-getargs
>>
>> I set things up in a way that allows the code to work inside ATS and also 
>> work as
>> a stand-alone package.
>>
>> On Wednesday, May 10, 2017 at 8:59:22 AM UTC-4, gmhwxi wrote:
>>>
>>> Good point!
>>>
>>> I have some ideas about this. I will make a package shortly.
>>>
>>> On Wed, May 10, 2017 at 1:00 AM, Artyom Shalkhakov  wrote:
>>>
>>>> Hi all,
>>>>
>>>> Is there a ready-made library for handling command line parameters?
>>>>
>>>> So far I found the following:
>>>>
>>>>
>>>> https://github.com/githwxi/ATS-Postiats/blob/master/utils/jsonlst2arr/jsonlst2arr.dats
>>>>
>>>> Which sets up an example of what HX thinks should be done to deal with 
>>>> command-line arguments. Would somebody like to move it into a library?
>>>>
>>>> -- 
>>>> 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 post to this group, send email to ats-lan...@googlegroups.com 
>>>> .
>>>> Visit this group at https://groups.google.com/group/ats-lang-users.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/ats-lang-users/3f70c312-504e-417c-8ee4-282cf0e22b41%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/3f70c312-504e-417c-8ee4-282cf0e22b41%40googlegroups.com?utm_medium=email_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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/53ba6d7e-c674-4d76-be88-cf78b050b3d0%40googlegroups.com.


Handling command line arguments?

2017-05-09 Thread Artyom Shalkhakov
Hi all,

Is there a ready-made library for handling command line parameters?

So far I found the following:

https://github.com/githwxi/ATS-Postiats/blob/master/utils/jsonlst2arr/jsonlst2arr.dats

Which sets up an example of what HX thinks should be done to deal with 
command-line arguments. Would somebody like to move it into a library?

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/3f70c312-504e-417c-8ee4-282cf0e22b41%40googlegroups.com.


Re: Packaging ats3d

2017-05-01 Thread Artyom Shalkhakov
Hongwei,

Sorry for this taking so much time but... at least I've prepared some 
images this time:

https://github.com/ashalkhakov/ats3d/

Onwards to getting your suggestions to work!

On Saturday, April 29, 2017 at 7:08:35 AM UTC+6, gmhwxi wrote:
>
> Sounds good!
>
> I only managed to make test01 work.
>
> For packaging, mylibies.hats is considered the entry point for the package.
> One should not be asked or should be discouraged to load files in SATS and
> DATS directly. If needed, please use ifdef-guards to control loading of 
> files.
>
> In your package, there are also CATS files. When these files are mentioned
> in SATS-files (or even DATS-files), please use a path like the following 
> one:
>
> /.../CATS/foo.cats
>
> For instance, you can use the following one:
>
> atscntrb-as-ats3d/src/CATS/vector.cats
>
> In your case, one also needs to compile various DATS-files
> in order to use ats3d. So I added mylibats_link.hats (where 'link'
> means that this file is for producing something needed at link-time).
>
> As for testing, tests inside TEST are for so-called internal testing.
> For testing packages externally, please visit:
>
> https://github.com/githwxi/ATS-Postiats-test/tree/master/package
>
> On Thursday, April 27, 2017 at 11:17:50 PM UTC-4, Artyom Shalkhakov wrote:
>>
>> 2017-04-28 9:11 GMT+06:00 gmhwxi <...>: 
>> > 
>> > I made some changes here: 
>> > 
>> > 
>> https://github.com/githwxi/ATS-Postiats-frozen/tree/master/projects/SMALL/atscntrb-as-ats3d-2017-04-27
>>  
>> > 
>> > # 
>> > 
>> > First, please change 
>> > 
>> > staload "../some-path" 
>> > 
>> > to 
>> > 
>> > staload "./../some-path" 
>> > 
>> > The first '.' means the directory in which the file containing 'staload 
>> > "./../some-path" 
>> > is located. 
>> > 
>> > I also added: mylibies.hats and mylibies_link.dats. The latter is for 
>> > generating code 
>> > needed  at link-time. 
>> > 
>> > Various occurrences of "../CATS/vector.cats" are changed into 
>> > 
>> > "atscntrb-as-ats3d/src/CATS/vector.cats" 
>> > 
>> > # 
>> > 
>> > 
>>
>> Thank you very much for the suggestions! I will take a look this weekend. 
>>
>> > On Thursday, April 27, 2017 at 11:58:44 AM UTC-4, Artyom Shalkhakov 
>> wrote: 
>> >> 
>> >> On Thursday, April 27, 2017 at 9:45:40 PM UTC+6, gmhwxi wrote: 
>> >>> 
>> >>> Thanks! 
>> >>> 
>> >>> Just tried it: 
>> >>> 
>> >>> 
>> >>> 
>> /home/ubuntu/workspace/mytmp/node_modules/atscntrb-as-ats3d/src/DATS/quaternion.dats:
>>  
>>
>> >>> 7079(line=343, offs=11) -- 7093(line=343, offs=25): error(3): the 
>> symbol 
>> >>> [.length] cannot be resolved due to too many matches: 
>> >>> D2ITMcst(length_vec3i) of 10 
>> >>> D2ITMcst(length_vec3f) of 10 
>> >>> 
>> >> 
>> >> Well, this isn't supported yet, sorry! I'm going to give quaternions a 
>> try 
>> >> once a proper scene description is done. I'm currently working on 
>> test04 
>> >> (will break it into separate modules soon); the goal is to create a 
>> >> feature-rich software rasterizer that mimics the OpenGL shading 
>> pipeline 
>> >> (I'm following https://github.com/ssloy/tinyrender as an 
>> inspiration). 
>> >> 
>> >>> 
>> >>> It seems that a type-annotation is needed for the if-expression. 
>> >>> 
>> >>> Also, there are files like xyz~ in the package. You may want to 
>> remove 
>> >>> them. 
>> >>> 
>> >> 
>> >> This is what I was trying to avoid. But maybe it's there because it 
>> got 
>> >> into version control... We'll see. 
>> >> 
>> >>> 
>> >>> 
>> >>> On Thursday, April 27, 2017 at 11:33:53 AM UTC-4, Artyom Shalkhakov 
>> >>> wrote: 
>> >>>> 
>> >>>> I made this package: 
>> >>>> 
>> >>>> https://www.npmjs.com/package/atscntrb-as-ats3d 
>> >>>> 
>> >>>> This is what I did: 
>> >>>> 
>> >>>> $ cd ats3d 
>> >>>> $ npm init 
>> >>>> ...answered some ques

Re: Packaging ats3d

2017-04-27 Thread Artyom Shalkhakov
I made this package:

https://www.npmjs.com/package/atscntrb-as-ats3d

This is what I did:

$ cd ats3d
$ npm init
...answered some questions (most notably, named the package 
[atscntrb-]; added ATS to the list of keywords)
...tried to figure out how .npmignore work (it didn't help me exclude a 
leftover README.md~ file, no idea why)
$ npm publish

That was very simple!

What are the mylibies/mydepies files? I'm still struggling to understand 
how external package dependencies are handled.

On Thursday, April 27, 2017 at 6:13:15 PM UTC+6, gmhwxi wrote:
>
> Sure :)
>
> On Thursday, April 27, 2017 at 2:56:23 AM UTC-4, Artyom Shalkhakov wrote:
>>
>> On Thursday, April 27, 2017 at 12:17:02 PM UTC+6, gmhwxi wrote:
>>>
>>>
>>> Packaging ATS code is largely undocumented at this point.
>>>
>>> I suggest that we use ats3d (https://github.com/ashalkhakov/ats3d)
>>> as a concrete example to illustrate some key steps involved in forming
>>> an npm-package for ATS code.
>>>
>>
>> I'll do it, will you wait for evening? Oh, I wanted to say: will you wait 
>> for 6 hours?
>>
>> I guess at this point, just creating a dummy package with sources will be 
>> enough? I have packaged some tiny library on NPM once.
>>
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/5540fe0a-a519-40ba-815a-56587b885c3b%40googlegroups.com.


Re: Packaging ats3d

2017-04-27 Thread Artyom Shalkhakov
On Thursday, April 27, 2017 at 12:17:02 PM UTC+6, gmhwxi wrote:
>
>
> Packaging ATS code is largely undocumented at this point.
>
> I suggest that we use ats3d (https://github.com/ashalkhakov/ats3d)
> as a concrete example to illustrate some key steps involved in forming
> an npm-package for ATS code.
>

I'll do it, will you wait for evening? Oh, I wanted to say: will you wait 
for 6 hours?

I guess at this point, just creating a dummy package with sources will be 
enough? I have packaged some tiny library on NPM once.

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/c81d7933-abc7-43a9-b970-b126e1a288d3%40googlegroups.com.


Re: The myatscc utility

2017-04-26 Thread Artyom Shalkhakov
Hi Hongwei,

On Wednesday, April 26, 2017 at 6:24:19 AM UTC+6, gmhwxi wrote:
>
>
> Often a file of ATS source code has to be compiled with the use of a 
> Makefile.
> This can be quite inconvenient in practice.
>
> When teaching, I have to answer countless questions regarding the need of 
> certain
> flags for compiling ATS code through the use of patscc/patsopt directly.
>
> I recently wrote a command 'myatscc' (which should be available to you if 
> you build
> the latest version of ATS (that is, ATS2-0.3.5). The simple idea behind of 
> 'myatscc' is
> like this:
>
> Given a file, say, foo.dats, one should be able to compile it by issuing 
> the following
> command:
>
> myatscc foo.dats
>
> Whatever needed for compiling foo.dats should be written as some form of 
> comment
> inside foo.dats. For instance, the following comment is assumed to be the 
> default (if
> nothing is given explicitly):
>
> (*
> ##myatsccdef=\
> patscc -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -o $fname($1) $1
> *)
>
> $1: the first non-flag argument passed to myatscc
> $fname: a built-in function for myatscc that returns the proper part of a 
> filename
>
> If you just want to see what myatscc generates (but not to execute what is 
> generated),
> please do:
>
> myatscc --dryrun foo.dats
>
> I am pretty sure that 'myatscc' will save a great deal of my own time :)
>
>
This is awesome!

Can it compile multi-module programs too? I currently have a very clumsy 
Makefile setup here:

https://github.com/ashalkhakov/ats3d/tree/master/src/TEST

(see specifically the Makefile)

The way I see it, it should be possible for the compiler (or some other 
tool) to infer module dependencies automatically?

Incidentally, we discussed the ways of automating programmer's workflow 
here:

https://github.com/RyanTKing/wombats/issues/1

I'm going to try to adapt the existing xmake project to tailor it to the 
needs of ATS programming. I don't have much time for this, at the moment, 
though.
 

> Cheers!
>

-- 
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 post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/afd17d79-6adf-4eb0-ba87-25ab466c7c6d%40googlegroups.com.


  1   2   >