Skip to content

Frequently asked questions

Brandon Barker edited this page Aug 9, 2014 · 19 revisions

Why does my code typecheck but not compile?

There could be several reasons, but please note specially the one in the compiler errors article referring to share/atspre_staload.hats.

ATS library code is GPLv3, so does this mean my compiled code also must be GPLv3?

Short answer: No.

Long answer: Think of the ATS2 compiler (ATS/Postiats) as if it were GCC.

If one uses GCC to generate object code from C source one owns, then one owns the generated object code. Then if you use ATS/Postiats to generate C code from ATS source you own, then you own the generated C code.

Longer answer:

ATSLIB is primarily used to generate C code, and the generated C code, which is owned by the author of its ATS source, can be compiled as long as the header files (that is, CATS-files) in ATS2-Postiats-include are available. Currently, ATS2-Postiats-include-0.1.1.tgz is released separately under a BSD-like license. Related to this, the preferred way to write portable ATS code should avoid using -latslib to generate executables.

Where can I find information on common pitfalls? Where can I ask newbie questions about writing ATS code?

First, read one of the official tutorials. Second, these ATS programming tips may be helpful. Third, there is a Google group, ats-lang-users for asking any kind of question, no matter how trivial, including slightly off-topic or less general-interest issues. Fourth, some of the discussions on the SourceForge mailing list archive may also prove instructive. Fifth, for other community resources, see the official community page.

For information about (the sometimes opaque) ATS error messages, see error messages on this wiki.

If you are not highly practiced with functional programming, it may be best to learn some Standard ML before learning ATS. The aid of SML textbook(s) or introductory ATS notes may be helpful.

Where can I find tutorials?

See tutorials on this wiki, or the Effective ATS series (also on git). Also see the answer to the previous question.

Where can I find some code or algorithm examples?

Several examples can be found here (ATS1).

Where can I find a reference or documentation?

For ATS, there is an unofficial (and incomplete) reference available (source). ATS2 has automatically generated library documentation. See the homepage on this wiki for links to wiki pages containing further documentation.

I'm getting type errors or unsolved constraints, but everything looks right. What might I be doing wrong?

Probably many things. Dependent types involve constraints; make sure you are using the right type at every step and not accidentally mixing similar types. There are many similar types in ATS (including functions with similar types) used for dealing with slightly different situations. We recommend avoiding heavy use of dependent types when starting out in order to avoid finding yourself in a situation with unsolved constraints that is very difficult to resolve. However, if and case expressions likely need to be annotated with types in general.

If you use emacs, consider using ATS Flymake as a possible measure to avoid such problems in the first place.

For examples of what can go wrong and some solutions see the following examples.

Finally, for some guidance on understanding certain errors, see error messages on this wiki.

I have two different types being used together in the same data structure, and they typecheck! Is this a bug?

After perhaps being exposed to the rigor of dependent types, one may occasionally be surprised: but the short answer is it probably isn't a bug. Here is an example where list0 will accept multiple values, each with a distinct type, as inputs (for example, strings, floats, or ints). Here is an example with templates. The notion has to do with "subtypes", and specifically, how ATS defines subtypes. This should not be a problem in ATS2, and is one of the major reasons for ATS2.

What are dependent types?

A dependent type is a type that depends on a value. As a simple example in ATS, int (5) is a type such that all integers belonging to it are equal to 5 (so it is in fact a singleton type).

What are linear types?

Linear types make use of linear logic. The notion of linear types may be explained as viewing variables as resources that are consumed by expressions, which allows for static resource tracking. For example, if you consider the expression (a or b), you've produced a new expression but you've destroyed a and b. This is useful for dealing with memory allocation safely and efficiently, for instance. For more information, see the ATS book, the Wikipedia article on linear types, or linear types on this wiki.

Is there a Windows version of ATS?

Not for the near future, at least. However, you can install ATS on top of Cygwin using the same build instructions as for other platforms.

You can also try ATS2 using this experimental online tool, or try using a virtual machine (see building and installing ATS).

Clone this wiki locally