How to write a simple program in ATS2

You need the following two lines at the beginning:

#include “atspre_define.hats”
#include “atspre_staload.hats”

Then you write your code. For instance:

fun hello (): void = println! “Hello, world!”

Then you need to implement a version of the ‘main’ function:

implement
main0 () =
{
//
val () = hello ()
//
} (* end of [main0] *)

Then you can compile your code by issuing the following command-line:

patscc -o hello hello.dats

where hello.dats is assumed to be the name of a file containing the above
code.

For testing, simply do

./hello

That it. Have fun!

–Hongwei

PS: there are some examples available at

${PATSHOME}/doc/EXAMPLE/INTRO

To access these example on-line, please follow the link below: