ATS: Programming with Theorem-Proving/Installing and operating the ATS compiler
Installing ATS[edit | edit source]
NOTE: these instructions have been tested on Ubuntu Linux, and may need to be changed for other distributions.
On Linux, the first step is to download the stable version of the current ATS compiler, ATS/Anairiats. The filename should be along the lines of "ats-lang-anairiats-x.x.x.tar.gz", where "x.x.x" stands for version.
Then you can install either into
/usr/share/atshome/ or into some directory under your home directory.
[edit | edit source]
Open a terminal and invoke
sudo tar xvzf ats-lang-anairiats-x.x.x.tar.gz /
Now add this to the environment:
ATSHOME=/usr/share/atshome export ATSHOME ATSHOMERELOC=ATS-x.x.x export ATSHOMERELOC PATH=$ATSHOME/bin:$PATH export PATH
Installing into home directory[edit | edit source]
If you choose to install in a different directory, say
~/FOO, untar into some temporary directory first:
tar xvzf ats-lang-anairiats-x.x.x.tar.gz /tmp
mv /tmp/usr/share/atshome ~/FOO
And then add the following to
ATSHOME=~/FOO/atshome export ATSHOME ATSHOMERELOC=ATS-x.x.x export ATSHOMERELOC PATH=$ATSHOME/bin:$PATH export PATH
An explanation of the meaning of the two environment variables is in order. Both are assumed to be non-empty.
ATSHOMEis an absolute path to the ATS installation directory
ATSHOMERELOCis a version of the installed ATS compiler, and is used for name mangling in the generated code
The first program[edit | edit source]
For testing, please write the following in your favorite text editor:
implement main () = print "hello, world!\n"
and save it into a file named
hello.dats. Then please issue the following command-line:
atscc -o hello hello.dats
If everything goes fine, then
./hello is a newly generated executable, which should print the string "Hello, world!" and a newline onto the console when executed.
File extensions[edit | edit source]
There are two major types of files you'll be interested in:
- files containing module interface, having the extension
.sats(the first letter comes from "statics")
- files containing implementation of interface, with the extension
.dats(the first letter comes from "dynamics")
The meaning of "statics" and "dynamics" will be explained later.