A brief update on ATS3 implementation

146 views
Skip to first unread message

gmhwxi

unread,
Dec 15, 2019, 9:08:21 PM12/15/19
to ats-lang-users
 Hi, there,

I would like to make a brief announcement, telling those in this group
about some recent progress made in the implementation of ATS3. The
project itself is publicly accessible at the following site:


Note that you need to have ATS2 installed in order to compile ATS3.

So far I have essentially finished the following parts, though changes and fixes
are definitely needed for a long time to come:

Part 1: Concrete syntax design + Parsing
Part 2: Binding resolution based on static scoping
Part 3: Type-inference + supporting for symbol overloading
Part 4: Type-based template code selection

I have also implemented a basic interpreter for testing.

Compiling ATS3 to C is scheduled in the next phase. After that. advanced type-checking
(for dependent types and linear types) needs to be supported.

Before starting the next phase, I plan to write some documentation and hope to get more
people on board. More on that later.

Cheers!

--Hongwei


gmhwxi

unread,
Dec 15, 2019, 9:22:48 PM12/15/19
to ats-lang-users

Here is some code implementing the Sieve of Erastosthenes.
Note that very little type annotation is needed (due to the much stronger support
for type-inference in ATS3 than in ATS2)

(* ****** ****** *)

fun
sieve
( xs
: stream(int)) =
$lazy
(
let
val xs
= $eval(xs)
in
case- xs of
|
strmcon_cons
(x0, xs) =>
strmcon_cons
(x0, sieve(filter(xs, x0)))
end
) (* end of [sieve] *)

and
filter
(xs, x0) =
$lazy
(
let
val xs
= $eval(xs)
in
case- xs of
|
strmcon_cons
(x1, xs) =>
(
 
if
 
(x1%x0=0)
 
then $eval(filter(xs, x0))
 
else strmcon_cons(x1, filter(xs, x0))
)
end // end of [filter]                                                                                                                                                                                                                                                        

(* ****** ****** *)

val
xs
=
sieve
(from(2)) where
{
fun
from
(n:int): stream(int) =
$lazy
(strmcon_cons(n, from(n+1)))
}

(* ****** ****** *)

val
-
strmcon_cons
(x0, xs) = $eval(xs)
val
-
strmcon_cons
(x1, xs) = $eval(xs)
val
-
strmcon_cons
(x2, xs) = $eval(xs)
val
-
strmcon_cons
(x3, xs) = $eval(xs)
val
-
strmcon_cons
(x4, xs) = $eval(xs)
val
-
strmcon_cons
(x5, xs) = $eval(xs)

(* ****** ****** *)

(* end of [sieve.dats] *)


Richard

unread,
Dec 15, 2019, 10:34:46 PM12/15/19
to ats-lang-users
Well done! Looking forward to the future progress.


On Sunday, December 15, 2019 at 9:08:21 PM UTC-5, gmhwxi wrote:

Brandon Barker

unread,
Jan 10, 2020, 2:39:48 PM1/10/20
to ats-lang-users
Great to hear about improved type inference! This quite wild to see in comparison to ATS2 code. 

I just hope that everyone remembers to annotate with types at least at the top-level; sometimes Haskellers don't do this and it makes the code more difficult to read, IMO (luckily that is a rarity) ;-)

Raoul Duke

unread,
Jan 10, 2020, 2:45:06 PM1/10/20
to ats-lan...@googlegroups.com
my usual usability rant: any language with inference must have a mode that inserts the ascii of what it inferred. 

--
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/cf089bb4-7a5e-4d46-a1c7-589c966ff246%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages